Crackling audio
Hello all,
I'm trying to recreate an ondes martenot. I've created a midi controller using some Arduinos, and they're sending the right data into max msp so I know that's not the issue.
Unfortunately, sometimes the audio that comes out of max crackles a lot and it sounds very bad. I've tried speakers and headphones, same issue on both. I attach the max patch (which I admit isn't entirely original, the sound generation part I found online, but the part that calculates pitchbends, trills etc. is mine). I would appreciate any help.
Thanks a lot.
That could be caused by too frequent changes you create with your objects,
and also when using data to change dsp signals.
Could you please elaborate? I'm a complete beginner so I am not sure what you mean by "dsp signal" and "objects".
dsp objects are ones that use signals
like all that tri~, rect~, etc.
You are producing too much repeated data
when calculating that float that sets frequency,
and also pass that float to slider, which again repeats it to all oscillators
but as rounded int
OK and what can I do about this?
interpolation.
first find out where the issue started, then interpolate either the audio signal which is controlling something or the one which you will hear at the output. it is usually best do correct it as early as possible.
it is a common problem with audio signals.
where do i start. imagine you have a tone of 100 hertz.
but you begin to play it at a sample value of 1.
this means that the sample value (the amplitude of the signal) will rise from 0 (before it starts, there is no signal, i.e. 0.) to the value 1 within 1/44100 seconds. this will create new frequencies up to 22050 hertz - which is what we call a click sound.
you can explore the phenomenon a bit with [click~] or by multipliying an existing signal output with 0 or by introducing a [gate~]
a standard situation is when you use a max message such as "1" to control an audio signal. in this case you usually transform the number into an audio signal first, and then filter the audio signal so that the transition from the first value to the new value happens somewhat slower than within one sample.
the line~ object can do both things in one go:
such a linear interpolation is not perfect, but a working solution in many cases.
it is always a compromise between reaction time and sound quality.
i am using 200 milliseconds in the example picture in order to see the effect on the [scope~]
200 milliseconds means that the click sound is now (mostly) limited to frequencies under 5 Hz. you can hear down to about 18 Hertz.
so a more realistic value for this application is 20-50 milliseconds, which equals 50-20 hertz. (easy to remember, isnt it?)
when working with audio signals - not only as newbie - always use visual feedback such as from the scope to understand or control what is going on.
Here's a video of what's happening, for the reference.
Having played around with this, I think I have a better idea of what the interpolation actually does.
What it seems I need to do is to read the FSR every 20-ish milliseconds, and just interpolate linearly from the previous FSR reading to the next one. How would I be able to achieve this?
I hear no crackling in your video.
You need to add the [pack] + [line~] basically everywhere abrupt changes can result in crackles, like at the [*~] just before the gigaverb, just after the [ctlin 7]. I went for a [pack f 30.] which will result in a linear slope of 30ms between every received value.
I've also added one at the output of the frequency you send to all oscillators, in order to smooth the frequency changes, although the problem should not come from here.
I also had to unfold your patch to understand what was going on, and did a bit of cleaning as there was some redundancy, as already pointed.
by "crackles" I meant those horrible distorted "banging" sounds coming out of my computer as soon as I pressed the FSR.
I kinda like them and don't find them distorted honestly!
Anyway, it's most likely because the sound send into the reverb goes from 0 to crazy high very quickly. So same issue as above, and same solution. I guess the FSR is sending MIDI on CC 4 or 5? I've already put a [pack] + [line~] after [ctlin 4], try to put one after [ctlin 5] (you will need to use [line] instead of [line~], as live.gain can only be controlled with regular data, not audio-rate.
Also try to increase the duration of these [line]/[line~] by increasing the value of 30 in the [pack] before.
Thank you so much!! You sorted the issue out. Actually, I didn't need to add anything else, and I found I could change the 30s to 10 and it sounds even snappier and without any crackles.