FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Programs
(Moderators: fry, REAS)
   Unexpected "Click" sounds in playing a sine wave
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Unexpected "Click" sounds in playing a sine wave  (Read 681 times)
elaine


Unexpected "Click" sounds in playing a sine wave
« on: Dec 26th, 2003, 7:24am »

I'm writing a program to play the sound of a simple sine waveform. I expected a smooth sound to be played, but the program always runs with constant "Click" sounds.
 
I tried the example in Proce55 -> examples -> sonic -> wave. This program allows user to change the waveform as well as the freq. But, the same "click" sound also appear even though I got a smooth sine wave in the screen. Is there any ways to solve such a problem? Or we must load a sound file in order to play a smooth sound?
 
I would be very grateful for any suggestions anyone might have.  
 
Thanks a lot!  
 
From,
Elaine
 
-------------------------------------------------------
// The sonic engine processes sounds at 8 bits, mono and 8000Hz.
 int sr = 8000;
 int total_duration = 10;
 int total_samples = total_duration*sr;
 
  void setup() {
   size(400, 400);
   stroke(255);
 
   // Initiate sound engine with a 512 audio buffer length
   beginSound(total_samples);
 }
 
 void soundEvent() {
 float freq = 500;
 
   for (int i=0; i < length; i++) {
     // Generate a sound using a sine wave
     samples[i] =  int(127 * sin(2*PI*freq*(i/(float)(total_samples-1))));
   }
 }
 
 void loop() {
   background(100);
   for (int i=0; i < length-1; i=i+1) {
     line(i*2, samples[i] + 120, i*2, samples[i+1] + 120  );
   }
 }
 
elaine


Re: Unexpected "Click" sounds in playing a sine wa
« Reply #1 on: Dec 26th, 2003, 2:57pm »

There is one modification in my coding.
For the second comment, it should be
 
// Initiate sound engine with a specified audio buffer length  
 
Sorry for any troubles caused!
 
Thanks,
Elaine
 
samChen
Guest
Email
Re: Unexpected "Click" sounds in playing a sine wa
« Reply #2 on: Jan 7th, 2004, 4:23am »

Try Sonia by Amit Pitaru
It extends the audio capabilities:
You can download it here:
http://www.pitaru.com/sonia/
 
You'll need to download Jsyn as well:
http://www.softsynth.com/jsyn/
 
elaine


Re: Unexpected "Click" sounds in playing a sine wa
« Reply #3 on: Jan 13th, 2004, 4:51am »

Thanks, samChen~
 
agree, Sonia is really helpful!!!
 
Pages: 1 

« Previous topic | Next topic »