Reputation: 117
I'm reading through Mark Owen's "Practical Signal Processing" and an exercise in the second chapter says to "Create a vector containing samples of several seconds of a 400Hz sine wave at 32kHz."(question 2.3)
Since the book doesn't endorse any one technology, I'm trying to do this in Supercollider with:
"Pbind(\freq, Pseq([400,400,400,400,400,400,400,400,400,400,]), \dur, 0.15;).play;"
but I have two problems: how do I remove the gap between the notes during pattern playback and how do I generate the tones in the pattern at a particular sample rate?
Thank you!
Upvotes: 0
Views: 79
Reputation: 4758
It sounds like you're working at the "wrong" level. Using Pbind is very high-level, specifying patterns of musical events, whereas the author presumably wants you to think about the maths involved in generating individual audio data samples.
Since it's an exercise for the reader I won't give a complete answer, but: SuperCollider has a sin()
operator as do many other languages. You can generate a list of values and then apply sin()
e.g. via
sin([0,1,2,3,4,5])
or
sin((0..100))
Those are simple examples; they don't get the frequency or sample rate or duration you specify.
The question doesn't seem to ask you to play back the result, but if you wanted to do that you could do it by loading your calculated audio into a Buffer:
x = sin((0..1000));
b = Buffer.sendCollection(s, x);
b.play
Upvotes: 2