Cabbage Logo
Back to Cabbage Site

Cabbage or Csound a semitone too high

Hello All,

I wonder if anybody else have also noticed that Cabbage instruments plays a semi-tone too high. My basic setup looks as follows:

Ubuntu Studio 16.04 with the bundled CSound 6.05. Would I be correct in assuming that this could be a CSound bug?

Regards,
Jan Henkins

Hi Jan,

Are you using Jack or Alsa? I’m seeing a similar thing over here.What’s your audio setup?

I have Jack running with a sample rate of 96000 Hz, buffer of 128 and period of 3. I also have the Alsa Loopback module loaded. The only way I can make my synths run is if Cabbage is configured to go through the Alsa Loopback interface and if sr in the Csound header equals that interface sampling rate (44100 Hz).

If I select Jack in Audio Settings I hear distorted sound and when it works it sounds 3/4 of a semitone higher or so. I’d suggest that you modify the sr setting and check again after.

Cheers.

I think @gsenna is right, sounds like a sample rate issue. But I’ve not had any audio issues with jack? It’s usually rock solid for me. Can’t say I’ve noticed any pitching problems either, but that doesn’t mean they don’t exist!

Rory, are you using Ubuntu Studio 16.04? How are you launching Jack? First of all, as I said, if I use Jack then sr must equal Jack’s sampling rate. Otherwise a simple sine sounds somewhere near an octave higher and distorted. That’s normal. But I also hear cracks even if sr is properly configured.

The recordings (fout+monitor) sound fine. Pure Csound with -+rtaudio=jack works fine. The problem must be when JUCE is talking to Jack.

Oh, and I have a question, is it normal that while selecting Jack in Cabbage, Csound says “rtaudio alsa module enabled”? I know you are accessing the sound buffer through GetSpout(), but does ALSA still has to be involved?

EDIT: I’ve found a hack for my problem. I set all the sample rates (JACK, ALSA Loopback and sr) to the same frequency. Then I configure Cabbage to use ALSA, but in the CsOptions I pass -odac -+rtaudio=jack. After that I disconnect the patch from the Loopback to system. That way I can use Csound’s Jack module. No more cracks in the sound. I hope we can solve the real problem though.

That sounds like quite a hack! I’m not on Ubuntu 16.04 yet. For last week, and this, I’m absolutely snowed under with exam corrections. After which I hope to upgrade my Ubuntu box and get back to some Cabbage development. I’m starting to get withdrawal symptoms!

Hello Rory and gsenna,

Very interesting behaviour! :smile: Anyhow, the sampling-rate tip was what did it for me. Everything is fine up to 44.1kHz (Frames/Period and Periods/Buffer settings did not seem to affect intonation), but from 48kHz upwards everything shifts up a semi-tone in all the Cabbage instruments I have tried. I will play around with pure Csound instruments and see whether I get the same behaviour.

Regards,
Jan Henkins

Hello All,

OK, so I did a few tests directly with Csound 6.07, and I cannot replicate the semitone thing. I tested from 44.1kHz up to 96kHz with the HarmonicAdditiveSynthesis1.csd file written by Iain McCurdy, and as suggested by gsenna I had to edit the “sr” value in the csd file to match the active Jack sample-rate. I was fully expecting to find that Csound goes up a semi-tone above 44.1kHz (it would have been a great “smoking gun” moment), but alas it is working properly.

Righty, so now I know to keep things down to 44.1kHz, at least for now. If this is perceived to be a bug, please let me help by testing scenarios. My platform is:

  • Ubuntu Studio 16.04
  • KXStudio repositories activated (for more up to date versions of Ardour, Carla, etc.)
  • CSound 6.07 (built from source, but I don’t mind downgrading back to 6.05 if that helps testing)

Regards,
Jan Henkins

Are you using -+rtaudio=jack in the options? There’s no way to test this with pure Csound as you can’t have a different sr other than the one used to start Jack. Otherwise, for example

system sr: 44100.000000
 *** rtjack: sample rate 96000 does not match JACK sample rate 44100

If you were using JACK in Cabbage then the problem was not about using a higher sample rate, but the mismatch between Csound (sr) and Cabbage-JUCE(Jack’s sample rate). As you can see from the error I posted above, pure Csound won’t even allow that to happen. I think Cabbage should also refuse to run if there’s a mismatch.

If you were using ALSA, then it could be that you had it configured to use hw: instead of plughw: or some of the other ALSA’s plugins, so that there was no resampling.

Having said that, I don’t know what the cause of my problem is. I hear noises. Jan, could you please try setting Cabbage to use JACK and then go nuts with the mouse over the keyboard of this synth? First change (sr) to match your JACK sample rate.

Harmonics.zip (9.4 KB)

Hello gsenna,

Yes, I started csound with the “-+rtaudio=jack” option. As I mentioned in my message, I had to edit the .csd file to match the sr value with which Jack was started up, otherwise it would exit with the expected error message.

Unfortunately I have run into other issues which prevents me from testing the file you attached, Cabbage itself is running rather badly on Ubuntu Studio 16.04 (which is off-topic for this particular thread, I will create a separate thread for this in a few days), so I will have to find some time on a Studio 15.10 machine I have around the house to do some meaningful testing.

Regards,
Jan Henkins

Cool. In 16.04 there’s the Zenity problem when you try to open or save an Instrument. The solution is to Use Native File Dialogues. Also I’ve seen weird behavior in the code editor regarding cursor position. I’ll open a new thread for that after some more testing.

Cheers.

The cursor problem might be to do with the selected font perhaps? If you don’t select a monospaced font things go strange very quickly. Then again, I thought I disabled all fonts that aren’t monospaced?

Yes, that was it! I had to manually choose the font for the Editor and after that it all went well. Maybe what happened is that after i upgraded to Ubuntu 16.04, the font in .Cabbage/Cabbage.settings was no longer available and for some reason it was back-falling to a non-monospaced font. Or something like that.

Jack still doesn’t work though. I’ll wait until you upgrade (Rory) to see if it’s 16.04 or just me.

Thanks.