Skip to content

Conversation

paulfd
Copy link
Member

@paulfd paulfd commented Feb 23, 2021

Note that the count opcode apparently counts the number of restarts. It also sets loop_mode to one_shot.

@paulfd paulfd force-pushed the loop-count branch 2 times, most recently from 9359ef3 to f3f2206 Compare February 23, 2021 22:40
@paulfd paulfd changed the title Add support for count Add support for count and loop_count Feb 23, 2021
@paulfd paulfd force-pushed the loop-count branch 2 times, most recently from ff65471 to 422e13d Compare February 23, 2021 23:43
@kinwie
Copy link

kinwie commented Feb 24, 2021

I think the description on the original sfz v1 specs is a little ambiguous.
But the implementation of count in sfz.dll, sforzando and Cakewalk DropZone almost the same, except for the 0 and 1 behavior.
The region plays as many times as the count number

@paulfd paulfd marked this pull request as ready for review February 27, 2021 09:16
@paulfd
Copy link
Member Author

paulfd commented Feb 27, 2021

@kinwie should be OK now !

@kinwie
Copy link

kinwie commented Feb 27, 2021

@paulfd Tested the new build for this. The count is fine now.

However, I encounter an issue for loop_count
The last portion of the sample after the loop is not played even I keep holding the key
Just in this simple example :

<region>
sample=snare_looped.wav
key=60
loop_count=3

After the loop, the snare will be cutoff. In Rapture and Sforzando, after the loop, it will play until the end of the sample.
Again, I know there is no detailed description for this opcode :))

@paulfd
Copy link
Member Author

paulfd commented Feb 27, 2021 via email

@kinwie
Copy link

kinwie commented Feb 27, 2021

Yes, in loop_sustain, the last portion of the sample after the loop, will be played after releasing the key and it controlled by ampeg_release

@paulfd
Copy link
Member Author

paulfd commented Mar 5, 2021

Okay so I revised all of this code to handle both the count, loop_count, and loop_mode with the differences between loop_sustain and loop_continuous.

I distinguished 3 cases:

  • loop_continuous: only loop on the sample. Upon release, the sample will continue to loop. If loop_count is also set, the voice will release itself after loop_counts loops but still continue to loop during the release phase.
  • loop_sustain: only loop on the sample until release, then play as if it were a normal sample. If loop_count is also set, the voice will release itself after loop_counts loops and play the part after the loop.
  • one_shot: well you ignore loop_count in this case but count is taken into account. In all loop_ cases count is ignored.

If there are loop points in the sample file and no loop_mode in the SFZ file, we set loop_mode to loop_continuous and apply the above behavior. Maybe if loop_count is present setting the loop mode to loop_sustain would make more sense? It looks like it's what sforzando does, if loop_count is present the loop_mode is set to loop_sustain by default.

I created a test file with a kick, a looping hi-hat and a crash to test stuff if various players if you like.
loop_count.zip

@kinwie
Copy link

kinwie commented Mar 6, 2021

I play your loop_count_test file in sforzando, DropZone and Rapture to compare to the current fix for loop_count.
Both sforzando and DropZone behave similar. I think in both, if loop_count is present loop_mode is set to loop_continuous, not loop_sustain.

From your test file, the loop_sustain is already fine.
Key d4 and f4 works similar like sforzando and DropZone.

Key e4 and g4 still not yet correct, imo, and I think the problem lies only at the loop_count behavior.
The behavior is, loop_count doesn't depend to the note-off message, unlike loop_sustain.

So,

  • When a note is held as long as the sample or longer, it will play looped N times +1 and continue to the end portion of the sample (loop-end point to end point) and at full volume
  • If the note released shorter than the sample and there is an ampeg_release, it will play looped N times +1 and continue to the end portion of the sample as long as value of ampeg_release (fade-out)

@kinwie
Copy link

kinwie commented Mar 8, 2021

I've checked the "Fine tune the looping behavior" build. The loop_count is now working fine 👍

Copy link
Collaborator

@jpcima jpcima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK to merge if it works

@paulfd paulfd merged commit 8b16f82 into sfztools:develop Mar 9, 2021
@paulfd paulfd mentioned this pull request Mar 9, 2021
3 tasks
@paulfd paulfd deleted the loop-count branch January 21, 2022 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants