Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dynamic crossfade #22

Closed
michaelwillis opened this issue Jan 11, 2020 · 12 comments · Fixed by #181
Closed

Implement dynamic crossfade #22

michaelwillis opened this issue Jan 11, 2020 · 12 comments · Fixed by #181
Assignees
Labels
improvement Improve on existing functionality

Comments

@michaelwillis
Copy link
Contributor

From issue #19:

Yes, the crossfade calculation are not dynamic right now and they're only checked when the note start. After reading around, this is indeed not what's expected so I'll look into it!

I'm opening this as a separate issue because the main bugs from that issue have been solved.

@paulfd paulfd self-assigned this Jan 16, 2020
@paulfd paulfd added the improvement Improve on existing functionality label Jan 16, 2020
@davidhealey
Copy link

davidhealey commented Jan 19, 2020

+1 for this. And make it smooth (Aria's implementation is horribly unusable, or I'm doing it wrong).

@michaelwillis
Copy link
Contributor Author

I made an attempt at implementing this in pull request #26.

@paulfd
Copy link
Member

paulfd commented Jan 19, 2020

@davidhealey as Michael implemented (and as I would have done it) there is a linear smoothing of the crossfade within a block. There are a couple different options (e.g. multiplicative or with a completely custom shape). If that's not rendering well enough for you we can try to tweak it 🙂

@davidhealey
Copy link

Excellent, I'll test it out

@davidhealey
Copy link

davidhealey commented Jan 19, 2020

I'm finding the crossfade choppy. I've tried both .flac and .wav files and found it made no difference. I did select to use a fixed buffer in Carla though and that improved it a little bit. It could of course be me doing something wrong with my SFZ opcodes.

I've uploaded the SFZ along with an mp3 of the output I get - https://www.dropbox.com/sh/nsbaq65jnkd98zq/AABTm8tK5zoPz7MOXJO8x6BTa?dl=0

@alcomposer
Copy link
Collaborator

alcomposer commented Jan 20, 2020

@davidhealey In the SFZ file there is no space in lines 22-34 inclusively- between:
xfout_hiccc1=127volume=-3

It should be:
xfout_hicc1=127 volume=-3

Sfizz reports: [INFO]: [sfizz] Unknown opcodes: 127volume

However I can confirm that in Ardour the crossfade is choppy.

@michaelwillis
Copy link
Contributor Author

I tested this a bit more thoroughly today. Crossfading in VPO works, but has a little bit of crackle:

https://www.dropbox.com/s/sclkx4h2kqiabjk/vpo_sfizz_crossfade_session_2020-01-19_22.40.mp3

After that I tried switching it to a multiplicative envelop, but with that, the audio cut out entirely after a few moments... @paulfd, any ideas?

@davidhealey
Copy link

davidhealey commented Jan 20, 2020

@davidhealey In the SFZ file there is no space in lines 22-34 inclusively- between:

Oh good catch! I assume it was still working with xfout but was ignoring the volume opcode.

I tested this a bit more thoroughly today. Crossfading in VPO works, but has a little bit of crackle:

What's VPO?

@alcomposer
Copy link
Collaborator

alcomposer commented Jan 20, 2020

@davidhealey VPO = Virtual Playing Orcehstra: http://virtualplaying.com/virtual-playing-orchestra/

@paulfd
Copy link
Member

paulfd commented Jan 20, 2020

There's a potential solution in 864fe57

I'm not super satisfied from a technical point of view. Just to give context, at least one issue was that when the CC event arrived at a small delay in the block, there would be hardly any smoothing made for the value---the envelopes are linearly interpolated otherwise. After thinking about it and looking around it seems that people mostly add a fixed ramp time, sforzando included. It also seems to me that this ramp should be a function of the block size, otherwise you will still have somewhat sharp edges in the envelopes and thus strange modulation in the signal. I've settled for block size / 2 in the commit, which is a bit high but is smoothest for my ears.

Another approach would be to lowpass-filter the envelope, which is also implied by the _smoothcc opcodes (https://sfzformat.com/modulations/smoothccN). A generic way to tackle this could then be to do coarse ramping by default and count on people to use the smoothing possibilities to clean it up if necessary.

In light of this, I think I should overhaul a bit my envelopes 🙂 Anyway for now tell me if it feels better like that!

@michaelwillis
Copy link
Contributor Author

The latest is working well for me. It turns out that some of the crackle I experienced was because I had the gain too high and it clipped the signal at the top of the crescendo.

@davidhealey How well does the latest update work for you?

@davidhealey
Copy link

It's much better but it's still not buttery smooth. I've added a second audio file to the dropbox folder. It's made from the same ardour session as the previous one, the only thing difference is the build of sfizz (and I fixed the volume opcode).

@paulfd paulfd added this to the 0.4.0 milestone Feb 14, 2020
@paulfd paulfd mentioned this issue Apr 13, 2020
5 tasks
@paulfd paulfd linked a pull request Apr 13, 2020 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improve on existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants