|
Author |
Topic: sinewave with a frequency of 440Hz? (Read 619 times) |
|
Koenie
|
sinewave with a frequency of 440Hz?
« on: Sep 7th, 2004, 5:56pm » |
|
Hello, I'm kinda stuck with this weird sound problem. I'm trying to play a sinewave at 440 Hz, but I can't figure out what sample-rate to use. I'm using Sonia's LiveOutput with an outputlength of 512. Here is the code I'm using: Code:int len = 512; int freq = 440; float amp = 0.5; float oneCycle = TWO_PI/len; void setup(){ size(200, 200); Sonia.start(this, 10000); LiveOutput.start(len, len*2); LiveOutput.startStream(); for (int i = 0; i < len; i++) { LiveOutput.data[i] = amp * sin(float(i * oneCycle * freq)); } } public void stop() { Sonia.stop(); super.stop(); } |
| I just used a sample-rate of 10000, because I really have no idea what sample-rate to use. It's probably hard to understand the way I explain it, but all I want is to play a sinewave sound at a frequency of 440 Hz. Can anyone please help me out? Thanks in advance, Koenie
|
http://koeniedesign.com
|
|
|
flight404
|
Re: sinewave with a frequency of 440Hz?
« Reply #1 on: Sep 7th, 2004, 9:44pm » |
|
Hey there Koenie... a similar but not quite thread going on over at 'liveoutput x 2'. I think this will help you out... http://www.pitaru.com/sonia/examples/LiveOutput_phase/index.html Hit the source code and see that Amit made a sine wave play at a specific frequency. I think this is what you need......
|
|
|
|
Koenie
|
Re: sinewave with a frequency of 440Hz?
« Reply #2 on: Sep 8th, 2004, 9:18pm » |
|
Thanks a lot, flight404, that was just what I needed. In case you were wondering what I wanted to use it for, I made a mini piano, to help explain a bit of text I'm writing . It's nothing special, just click and drag the mouse over it. http://koeniedesign.com/tmp/keyboard/ Koenie
|
http://koeniedesign.com
|
|
|
|