Skip to content

Commit

Permalink
Don't add extra samples to output when fade is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
astoniab committed Jun 11, 2023
1 parent fa12dd4 commit af413b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Funscript To E-Stim Audio Converter (fork of edger477 version with mods)
- Add metadata to generated mp3 to see the settings that were used
- Ability to create multiple output files with stroke timing between minimum and maximum values
- Ability to create an output file with customized stroke timing
- Adjusted fade in/out so it won't add extra samples to the output, it will only fade the existing samples already present
8 changes: 5 additions & 3 deletions funstim.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ onmessage = e => {
let samplesPerMs = e.sampleRate / 1000;
let normalSamples = length * samplesPerMs;
let fadeSamples = e.fade * samplesPerMs;
let totalSamples = normalSamples + fadeSamples * 2;
//let totalSamples = normalSamples + fadeSamples * 2;
let totalSamples = normalSamples; // fade won't "add" samples to output anymore. Output length will match funscript end length
let sample = 0;
let actionIndex = 0;

Expand Down Expand Up @@ -110,10 +111,11 @@ onmessage = e => {
amp = 1;
}

// fade at beginning and end of file (if selected).
if (sample < fadeSamples) {
amp = Math.min(amp, sample / fadeSamples);
} else if (sample >= normalSamples) {
amp = Math.max(0, Math.min(amp, 1 - (sample - normalSamples) / fadeSamples));
} else if (sample >= (normalSamples - fadeSamples)) {
amp = Math.max(0, Math.min(amp, (normalSamples - sample) / fadeSamples));
}

let filterLength = (e.sampleRate * e.fade) / 1000;
Expand Down

0 comments on commit af413b5

Please sign in to comment.