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

Default sound is sharp #1

Closed
riban-bw opened this issue Mar 19, 2024 · 9 comments
Closed

Default sound is sharp #1

riban-bw opened this issue Mar 19, 2024 · 9 comments

Comments

@riban-bw
Copy link

The default sound that emits when the LV2 is hosted for the first time reacts to MIDI input with an audio output that is too high in frequency.

Running on Zynthian V5 Oram (arm64).
Commit: 50f0828 (current master).

@polluxsynth
Copy link
Owner

By 'too high', do you mean 'supersonic', 'several octaves above what one would consider a useful musical pitch' (i.e. a couple of thousand Hertz) or just 'slightly sharp' (like 50 cents or so) ?

@riban-bw
Copy link
Author

Probably about a semitone. I will check more accurately later.

@riban-bw
Copy link
Author

Audio seems +1.5 semitones (+150 cents).

@polluxsynth
Copy link
Owner

Hm, that's about the difference between 44100 and 48000 as well. Thanks, I'll look into it.

@riban-bw
Copy link
Author

I am running at 48000 FPS.

@polluxsynth
Copy link
Owner

That's good input, sounds there's a sample rate setting call that gets lost. (MiMi-d by default sets up 44100 just to set up something).

BTW the default sample rate for Zynthian is 44100 isn't it? Is it still set like in this thread?
https://discourse.zynthian.org/t/zynthian-s-sample-rate/557/6

@riban-bw
Copy link
Author

I think you may be right. I see that the constructor sets samplerate to 44100 and I don't see anything that changes it. There is a callback to set samplerate if changed by host but this won't do anything whilst the plugin is active (distrho behaviour) and won't be called if the host does not change samplerate.

LV2 host will pass the samplerate to the plugin on instantiation and I believe distrho uses this by default so it may not be necessary to set it explicitly. You can retrieve it with double Plugin::getSampleRate().

@riban-bw
Copy link
Author

Zynthian is 44100 out of the box but I want to lobby for this to change. It has the advantage of reducing processing cycles which may improve performance. (I have run stuff at 32000 when 15kHz bandwith is sufficient, e.g. modelling old synths.) 48000 can be a simpler number to process which can reduce load. 48000 is the industry standard in most audio industries. (Only CDs use 44100 for a funny historical reason.) But mostly I currently want 48000 because I am adding Jamulus support that uses the Opus CODEC that only runs at 48000. (Opus supports fractions of this but Jamulus is fixed at 48000.)

@polluxsynth
Copy link
Owner

polluxsynth commented Mar 20, 2024

LV2 host will pass the samplerate to the plugin on instantiation and I believe distrho uses this by default so it may not be necessary to set it explicitly. You can retrieve it with double Plugin::getSampleRate().

Thanks for the research. Sounds like getSampleRate is the solution. I'll try to check it out this evening.

EDIT: Spot on, adding getSampleRate to the constructor fixes the issue.

polluxsynth pushed a commit that referenced this issue Mar 21, 2024
Instead of a fixed sample rate of 44100, set the initial sample
rate from the plugin framework.

(The SampleRateChanged() callback is only called by the
framework when the sample rate is actually changed).
polluxsynth pushed a commit that referenced this issue Mar 29, 2024
Instead of a fixed sample rate of 44100, set the initial sample
rate from the plugin framework.

(The SampleRateChanged() callback is only called by the
framework when the sample rate is actually changed).
polluxsynth pushed a commit that referenced this issue Mar 30, 2024
Instead of a fixed sample rate of 44100, set the initial sample
rate from the plugin framework.

(The SampleRateChanged() callback is only called by the
framework when the sample rate is actually changed).
polluxsynth pushed a commit that referenced this issue Apr 2, 2024
Instead of a fixed sample rate of 44100, set the initial sample
rate from the plugin framework.

(The SampleRateChanged() callback is only called by the
framework when the sample rate is actually changed).
polluxsynth pushed a commit that referenced this issue Apr 4, 2024
Instead of a fixed sample rate of 44100, set the initial sample
rate from the plugin framework.

(The SampleRateChanged() callback is only called by the
framework when the sample rate is actually changed).
polluxsynth pushed a commit that referenced this issue Apr 7, 2024
Instead of a fixed sample rate of 44100, set the initial sample
rate from the plugin framework.

(The SampleRateChanged() callback is only called by the
framework when the sample rate is actually changed).
polluxsynth pushed a commit that referenced this issue Apr 17, 2024
Instead of a fixed sample rate of 44100, set the initial sample
rate from the plugin framework.

(The SampleRateChanged() callback is only called by the
framework when the sample rate is actually changed).
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

No branches or pull requests

2 participants