Designing equations and additive synthesis question tia sal22
Greetings All
I'm trying to find a tutorial that will allow me to create sound from an equation.
I now about the expr command but I've been unable to find one that creates a simple sound using the sin wave equation with adjustable variables. I know I could just use cycle~ But my equations are a half a page of sines and cosines. Do you know of a simple example like this equation
y = A*sin(w*x)+cos(w*x)+d that will allow me to adjust the variables x,d and A and play the audio file.
Here's a very small sample of the equations I would like to put into max msp and
have it play, along with some of the adjustable variable names.
y= -0.00000000+VERTOFFmain_1+aad_1
+((AMPmain_1+aaa_1)*0.000000000021538)*cos((FREQmain_1+aab_1)* 1.0 *(t-(((PHASEmain_2-PHASEmain_1)+aac_1)/(FREQmain_1+aab_1))))
+((AMPmain_1+aaa_1)*0.000000302338232)*sin((FREQmain_1+aab_1)* 1.0 *(t-(((PHASEmain_2-PHASEmain_1)+aac_1)/(FREQmain_1+aab_1))))
+((AMPmain_1+aaa_1)*0.000000000086163)*cos((FREQmain_1+aab_1)* 2.0 *(t-(((PHASEmain_2-PHASEmain_1)+aac_1)/(FREQmain_1+aab_1))))
+((AMPmain_1+aaa_1)*0.000000604757095)*sin((FREQmain_1+aab_1)* 2.0 *(t-(((PHASEmain_2-PHASEmain_1)+aac_1)/(FREQmain_1+aab_1))))
+((AMPmain_1+aaa_1)*0.000000000193911)*cos((FREQmain_1+aab_1)* 3.0 *(t-(((PHASEmain_2-PHASEmain_1)+aac_1)/(FREQmain_1+aab_1))))
aloha
Rick
Well, I don't see why you should not be able to create an
audio rate implementation of y = A*sin(w*x)+cos(w*x)+d
Look at sig~, *~, +~, sin, and cos.
The thing is the equation is about 150 lines long. And it's easier to put it into one equation than to have 1000 sig~ in max/msp I can automatically create the one equation but I can't automatically create the sig~ and their values and each node it would require. So all I'm looking for is a simple example like this equation
y = A*sin(w*x)+cos(w*x)+d that will allow me to adjust the variables x,d and A and play the audio file. Without using multiple sig~.
Simple Example: One equation with 3 variables
1) use the equation y = A*sin(w*t)+cos(w*t)+d creates the waveform shape
2) can edit the A,w,d
3) plays the waveform.
Is this possible?
The problem is there is no object that I know of that does audio rate expr. Basically you would have to create your own external that would do it.
If you can code, I would recommend you do that.
Alternatively, you could create an abstraction that would contain
the Max implementation of y = A*sin(w*x)+cos(w*x)+d, then you could
use scripting commands to create as many instances of it as you wanted
with what ever parameters you wanted. And sum them all together.
I agree with Anthony that there is no built-in object in Max that will do this.
If you don't want to go through the learning curve of creating your own external in C you can always try the MSP implementation in Max's Java environment, mxj. You'll have to learn Java of course, but it's probably a bit smaller of a hill to climb...
I would be willing to tackle java if I could find examples for what I'm trying to do. Has no one asked for this before? I would like to create a waveform using an equation and have that waveform played, I didn't think I was asking a lot. Maybe it's more difficult to program than I thought.
You could use one of the external synth/dsp language objects to do this, [chuck~] or [csound~] would probably be easiest to learn, [sc3~] could also do it, think.
Look in the java-doc folder - there's a PDF called "WritingMaxExternalInJava.pdf". Page 43 - Writing Signal Processing Objects in Java Using mxj~.
There's also a folder there called "mxj~ examples" with source code.
Csound will do this very well, but it has its own learning curve.
One you may not want to climb.
I think what you need is an external that lets you specify a sine wave
and how many partials and partial strength. Have you looked at oscbank~?
You could bang expr as fast as you can, send it through sig~ and then rampsmooth~ to interpolate up to audio sample rate. Frankly though, I used this for signal with play~, not audio synthesis, and still heard some significant artifacts. I was able to eliminate them by editing my sample a bit, but maybe someone who knows more about audio than me could make a filter to deal with this.
Hi there, ultimately if you want to create some kind of (static) harmonic wavetable,
may I suggest using [gen10] from percolate (GEN10 also exists in Csound).
If you opt for SuperCollider as noted above, check the "/b_gen" command in the Server-Command-Reference and DynKlang.ar/Klang.ar!
Finally, you could think of implementing your equations as a [js] (JavaScript) object, sending values to control an (i)oscbank~
Cheers
Panos
Simple Example: One equation with 3 variables
1) use the equation y = A*sin(w*t)+cos(w*t)+d creates the waveform shape
2) can edit the A,w,d
3) plays the waveform.
why not [uzi], [expr], then peek~ to write the values to a buffer? I did this in a past project to create buffers out of sin functions, with adjustable coeffs and power functions. Just change the [expr] to whatever function you want, choose how many samples you want to generate, and use the appropriate [scale] to get the range of values you want (probably between -1. and 1.). The calculations aren't totally smooth but they're plenty fast to experiment with.
The functions are limited, but you can get a lot of interesting sounds out of it, especially when you choose the different sections of the waveforms to play back and the playback rates. You can also record the audio and automate some of the parameters.
Thanks seejayjames your patch looks great!!! it looks like what I exactly want to do, the only problem is I'm having some issue deciphering the code do you have a simpler version handy?