We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › crackle on mute and unmute in minim
Page Index Toggle Pages: 1
crackle on mute and unmute in minim (Read 855 times)
crackle on mute and unmute in minim
Jan 14th, 2009, 6:50pm
 
Is there a good way to avoid crackles when unmuting? I have modified this example:
http://code.compartmental.net/minim/examples/AudioOutput/SineWaveSignal/
to only play when the mouse button is down, but it crackles a bit when I press and realease the mouse button. Is there some easy way to avoid this?

Here is the code:

import ddf.minim.*;
import ddf.minim.signals.*;

Minim minim;
AudioOutput out;
SineWave sine;

void setup()
{
 size(512, 600, P3D);

 minim = new Minim(this);
 // get a line out from Minim, default bufferSize is 1024, default sample rate is 44100, bit depth is 16
 out = minim.getLineOut(Minim.STEREO);
 // create a sine wave Oscillator, set to 440 Hz, at 0.5 amplitude, sample rate from line out
 sine = new SineWave(440, 0.5, out.sampleRate());
 // set the portamento speed on the oscillator to 200 milliseconds
 //sine.portamento(20);
 // mute the line out
 out.mute();
 // add the oscillator to the line out
 out.addSignal(sine);
 out.printControls();
}

void draw()
{
 background(0);
 stroke(255);
 // draw the waveforms
 for(int i = 0; i < out.bufferSize() - 1; i++)
 {
   float x1 = map(i, 0, out.bufferSize(), 0, width);
   float x2 = map(i+1, 0, out.bufferSize(), 0, width);
   line(x1, 50 + out.left.get(i)*50, x2, 50 + out.left.get(i+1)*50);
   line(x1, 150 + out.right.get(i)*50, x2, 150 + out.right.get(i+1)*50);
 }
}

void mousePressed()
{
   out.unmute();
}

void mouseMoved()
{
   float freq = map(mouseY, 0, height, 1500, 60);
   sine.setFreq(freq);
   // pan always changes smoothly to avoid crackles getting into the signal
   // note that we could call setPan on out, instead of on sine
   // this would sound the same, but the waveforms in out would not reflect the panning
   //float pan = map(mouseX, 0, width, -1, 1);
   //sine.setPan(pan);
}

void mouseReleased()
{
 out.mute();
}

void stop()
{
 out.close();
 minim.stop();

 super.stop();
}
Re: crackle on mute and unmute in minim
Reply #1 - Apr 1st, 2009, 2:51pm
 
Have you had any luck fixing this?

I am having the exact same problem when trying to trigger a high number of audiofiles. Each time I click the mouse to trigger a new sound there is a crackle. This goes for AudioPlayer, AudioSample and AudioSnippet.

Page Index Toggle Pages: 1