Forums > MaxMSP

creating waveforms

Jun 24 2008 | 6:24 am

A sawtooth wave form is the representation of all integer harmonics. A square wave represents all odd numbers.
Who could tell me how I could program a wave form based on prime numbers only?
Also, when a sine wave can be geometrically represented as a circle, a sawtooth as a triangle and a square wave by a square. What geometry would a prime number wave take?

What (theoritical?)wave form would a cube have to have?

(Sorry, this is not a 10000 Dollar question…)

Jun 24 2008 | 7:25 am

Quote: hans.mittendorf@free.fr wrote on Tue, 24 June 2008 08:24
—————————————————-
> A sawtooth wave form is the representation of all integer harmonics. A square wave represents all odd numbers.
> Who could tell me how I could program a wave form based on prime numbers only?

It depends on the amplitude of the partials. The easiest way to test this is to use a oscillator bank or poly~ with sinewaves. But since primes 1, 2 and 3 are going to be most influential on the sound as the lowest partials, I wouldn’t have too high expectations. You could make the choice to start a higher primes.

> Also, when a sine wave can be geometrically represented as a circle, a sawtooth as a triangle and a square wave by a square.

Here you mix two types of representation. A circle can be constructed with a sine for the y-axis and a cosine for the x-axis.

> What (theoritical?)wave form would a cube have to have?

A cube is three dimensional. I don’t understand the question.

_
johan

Jun 24 2008 | 1:36 pm

Hans Mittendorf schrieb:
> (Sorry, this is not a 10000 Dollar question…)

would 10 be enough?

I came up recently with this to play around:

— Pasted Max Patch, click to expand. —

Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
— _|_)—-|—–()————–
———-()——–www.ccmix.com

Jun 24 2008 | 7:27 pm

wow, really not bad. It makes clicks, I think it needs quantizing….

Jun 24 2008 | 7:35 pm

On Jun 23, 2008, at 11:24 PM, Hans Mittendorf wrote:

> Who could tell me how I could program a wave form based on prime
> numbers only?

I have an example, that may prove interesting, called PartialWorkshop,
that I did many years ago. It allows for manipulation of the first 64
harmonics of a sound.

-C

Chris Muir
cbm@well.com

Jun 25 2008 | 8:19 am

Hi Chris,

that’s well done!

I made a prime number wave. It works well. When I used TestSnap it did not store the waveform in the buffer. How do I record it into buffer?

Thanks

Jun 25 2008 | 11:03 am

while we’re on this subject… did anyone try to make a general
solution for constructing anti-aliased waveforms? i was thinking
thought..

if anyone could share some insight, i would greatly appreciate it!

/m

25 jun 2008 kl. 10.19 skrev Hans Mittendorf:

>
> Hi Chris,
>
> that’s well done!
>
> I made a prime number wave. It works well. When I used TestSnap it
> did not store the waveform in the buffer. How do I record it into
> buffer?
>
> Thanks

Jun 25 2008 | 4:30 pm

On Jun 25, 2008, at 1:19 AM, Hans Mittendorf wrote:

> I made a prime number wave. It works well. When I used TestSnap it
> did not store the waveform in the buffer. How do I record it into
> buffer?

You should be able to record it by editing the patch to add a record~
or sfrecord~ system pretty easily. Hang it off of either the gain~
slider or the subpatcher "theSines."

If I was making this patcher today, I would probably use the CNMAT

-C

Chris Muir
cbm@well.com

Jun 25 2008 | 4:40 pm

On Jun 25, 2008, at 4:03 AM, Mattias Petersson wrote:

> while we’re on this subject… did anyone try to make a general
> solution for constructing anti-aliased waveforms? i was thinking
> thought..

In my PartialWorkshop patch, because it’s additive and each sine is
controlled individually, I do a simple calculation: if the sine
frequency is > 20KHz, don’t play it. It’s antialiasing, albeit sort of
crude.

-C

Chris Muir
cbm@well.com

Jun 25 2008 | 9:17 pm

>> hile we’re on this subject… did anyone try to make a general
>> solution for constructing anti-aliased waveforms? i was thinking
>> thought..
>
>
> In my PartialWorkshop patch, because it’s additive and each sine is
> controlled individually, I do a simple calculation: if the sine
> frequency is > 20KHz, don’t play it. It’s antialiasing, albeit sort
> of crude.
thanks! it’s a nice patch!
but as you wrote, this works because it’s additive. i’m more
interested in using arbitrary soundfiles or randomized data in
buffers as waveforms. but i still would like to get rid of the aliasing.

/m

Jun 25 2008 | 10:10 pm

On Jun 25, 2008, at 2:17 PM, Mattias Petersson wrote:
> but as you wrote, this works because it’s additive. i’m more
> interested in using arbitrary soundfiles or randomized data in
> buffers as waveforms. but i still would like to get rid of the
> aliasing.

As far as I know, once you’re in the digital domain, just about the
only way to get rid of aliasing when changing the rate/pitch of audio,
is through oversampling & digital filtering (fancy interpolation) in
the rate change process. I don’t think that you can just create anti-
aliased buffers.

-C

Chris Muir
cbm@well.com

Jun 26 2008 | 8:37 pm

Chris Muir schrieb:
> As far as I know, once you’re in the digital domain, just about the only
> way to get rid of aliasing when changing the rate/pitch of audio, is
> through oversampling & digital filtering (fancy interpolation) in the
> rate change process. I don’t think that you can just create anti-aliased
> buffers.

With waveforms you could create additional filtered waveforms in
additional buffer. Then switch to a different buffer if you get higher
in pitch… To get steep filters use fft, and zero the higher bins, then
rerecord outside of the fft.

save as fftbricks~

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 702 83 38 196617 >> 8;
#P newex 626 83 38 196617 >> 7;
#P newex 551 83 38 196617 >> 6;
#P newex 474 83 38 196617 >> 5;
#P newex 398 83 38 196617 >> 4;
#P newex 323 83 38 196617 >> 3;
#P newex 246 83 38 196617 >> 2;
#P newex 170 83 38 196617 >> 1;
#P newex 663 116 49 196617 < ~ 8;
#P newex 587 116 49 196617 < ~ 16;
#P newex 512 116 49 196617 < ~ 32;
#P newex 435 116 49 196617 < ~ 64;
#P newex 359 116 49 196617 < ~ 128;
#P newex 284 116 49 196617 < ~ 256;
#P newex 207 116 49 196617 < ~ 512;
#P newex 131 116 49 196617 < ~ 1024;
#P newex 599 194 50 196617 fftout~ 8;
#P newex 639 161 34 196617 *~ 1.;
#P newex 599 161 34 196617 *~ 1.;
#P newex 563 161 34 196617 *~ 1.;
#P newex 523 161 34 196617 *~ 1.;
#P newex 487 161 34 196617 *~ 1.;
#P newex 447 161 34 196617 *~ 1.;
#P newex 411 161 34 196617 *~ 1.;
#P newex 371 161 34 196617 *~ 1.;
#P newex 335 161 34 196617 *~ 1.;
#P newex 295 161 34 196617 *~ 1.;
#P newex 259 161 34 196617 *~ 1.;
#P newex 219 161 34 196617 *~ 1.;
#P newex 183 161 34 196617 *~ 1.;
#P newex 143 161 34 196617 *~ 1.;
#P newex 107 161 34 196617 *~ 1.;
#P newex 67 161 34 196617 *~ 1.;
#P newex 170 46 110 196617 fftinfo~;
#P newex 523 194 50 196617 fftout~ 7;
#P newex 447 194 50 196617 fftout~ 6;
#P newex 371 194 50 196617 fftout~ 5;
#P newex 295 194 50 196617 fftout~ 4;
#P newex 219 194 50 196617 fftout~ 3;
#P newex 143 194 50 196617 fftout~ 2;
#P newex 67 194 50 196617 fftout~ 1;
#P newex 67 46 90 196617 fftin~ 1;
#P connect 0 0 9 0;
#P connect 9 0 1 0;
#P connect 26 0 9 1;
#P connect 0 1 10 0;
#P connect 10 0 1 1;
#P fasten 0 2 26 0 152 104 136 104;
#P connect 26 0 10 1;
#P fasten 0 0 11 0 72 152 148 152;
#P connect 11 0 2 0;
#P connect 27 0 11 1;
#P fasten 8 1 34 0 208 73 175 73;
#P connect 34 0 26 1;
#P fasten 0 1 12 0 112 144 188 144;
#P connect 12 0 2 1;
#P fasten 0 2 27 0 152 104 212 104;
#P connect 27 0 12 1;
#P fasten 0 0 13 0 72 152 224 152;
#P connect 13 0 3 0;
#P connect 28 0 13 1;
#P fasten 8 1 35 0 208 73 251 73;
#P connect 35 0 27 1;
#P fasten 0 1 14 0 112 144 264 144;
#P connect 14 0 3 1;
#P connect 28 0 14 1;
#P fasten 0 2 28 0 152 104 289 104;
#P fasten 0 0 15 0 72 152 300 152;
#P connect 15 0 4 0;
#P connect 29 0 15 1;
#P fasten 8 1 36 0 208 73 328 73;
#P connect 36 0 28 1;
#P fasten 0 1 16 0 112 144 340 144;
#P connect 16 0 4 1;
#P fasten 0 2 29 0 152 104 364 104;
#P connect 29 0 16 1;
#P fasten 0 0 17 0 72 152 376 152;
#P connect 17 0 5 0;
#P connect 30 0 17 1;
#P fasten 8 1 37 0 208 73 403 73;
#P connect 37 0 29 1;
#P fasten 0 1 18 0 112 144 416 144;
#P connect 18 0 5 1;
#P fasten 0 2 30 0 152 104 440 104;
#P connect 30 0 18 1;
#P fasten 0 0 19 0 72 152 452 152;
#P connect 19 0 6 0;
#P connect 31 0 19 1;
#P fasten 8 1 38 0 208 73 479 73;
#P connect 38 0 30 1;
#P fasten 0 1 20 0 112 144 492 144;
#P connect 20 0 6 1;
#P connect 31 0 20 1;
#P fasten 0 2 31 0 152 104 517 104;
#P fasten 0 0 21 0 72 152 528 152;
#P connect 21 0 7 0;
#P connect 32 0 21 1;
#P fasten 8 1 39 0 208 73 556 73;
#P connect 39 0 31 1;
#P fasten 0 1 22 0 112 144 568 144;
#P connect 22 0 7 1;
#P fasten 0 2 32 0 152 104 592 104;
#P connect 32 0 22 1;
#P fasten 0 0 23 0 72 152 604 152;
#P connect 23 0 25 0;
#P connect 33 0 23 1;
#P fasten 8 1 40 0 208 73 631 73;
#P connect 40 0 32 1;
#P fasten 0 1 24 0 112 144 644 144;
#P connect 24 0 25 1;
#P fasten 0 2 33 0 152 104 668 104;
#P connect 33 0 24 1;
#P fasten 8 1 41 0 208 73 707 73;
#P connect 41 0 33 1;
#P window clipboard copycount 42;

save as whatever…

#P window setfont "Sans Serif" 9.;
#P number 38 71 35 9 1 8 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 38 157 327 196617 selector~ 9 1;
#P user spectroscope~ 38 234 300 100 20 0 0 0 1 1 0 0 0 0 0 0;
#X frgb 224 224 224;
#X brgb 255 255 255;
#X rgb2 0 0 0;
#X rgb3 243 204 204;
#X rgb4 255 0 0;
#X rgb5 184 184 184;
#X rgb6 0 0 0;
#X rgb7 0 0 0;
#X rgb8 255 255 255;
#X rgb9 255 0 0;
#X rgb10 255 191 0;
#X rgb11 0 191 127;
#X rgb12 127 0 127;
#X rgb13 0 0 0;
#X range 0. 1.2;
#X domain 0. 22050.;
#X done;
#P newex 100 61 50 196617 noise~;
#P newex 108 120 258 196617 pfft~ fftbricks~ 2048;
#P connect 1 0 3 1;
#P connect 1 0 0 0;
#P connect 0 7 3 9;
#P connect 4 0 3 0;
#P connect 3 0 2 0;
#P connect 0 0 3 2;
#P connect 0 1 3 3;
#P connect 0 2 3 4;
#P connect 0 3 3 5;
#P connect 0 4 3 6;
#P connect 0 5 3 7;
#P connect 0 6 3 8;
#P window clipboard copycount 5;

Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
— _|_)—-|—–()————–
———-()——–www.ccmix.com

Jun 27 2008 | 11:18 am

> With waveforms you could create additional filtered waveforms in
> additional buffer. Then switch to a different buffer if you get higher
> in pitch… To get steep filters use fft, and zero the higher bins,
> then
> rerecord outside of the fft.
thanks Stefan! this seems to be the best way to go for me.

/m

Jun 29 2008 | 7:21 pm

Chris,
Thanks a lot for the Partial Workshop. This will no doubt be great for a relative newbie like me to study. One question has arisen for me, looking at the "Partial" subpatch. What is the advantage of running phasor~ into the phase inlet of cycle~ rather than simply running the frequency straight into cycle~ itself?

Jun 29 2008 | 7:48 pm

On Jun 29, 2008, at 12:21 PM, Jay Bodley wrote:
> What is the advantage of running phasor~ into the phase inlet of
> cycle~ rather than simply running the frequency straight into cycle~
> itself?

Because all the oscillators for the partials are free-running, I
needed a way to sync them. Using the phasor~ allowed for this.

I know I keep saying this, but if I was doing this patch today, I
would probably be using some of the additive stuff from CNMAT, FWIW.

-C

Chris Muir
cbm@well.com

Jun 29 2008 | 7:54 pm

And why can this not be done in the right inlet of cycle~? I am under the impression it serves the same function as phasor~’s right inlet.

Jun 29 2008 | 8:45 pm

On Jun 29, 2008, at 12:54 PM, Jay Bodley wrote:
> And why can this not be done in the right inlet of cycle~? I am
> under the impression it serves the same function as phasor~’s right
> inlet.

I don’t think that that’s true:

#P window setfont "Sans Serif" 9.;
#P window linecount 4;
#P comment 130 169 164 196617 Note that you only hear a click when
pressing the Sync button when listening to the Phasor -> Cycle;
#P window linecount 1;
#P comment 244 37 82 196617 Phasor -> Cycle;
#P message 371 193 37 196617 \$1 30;
#P message 58 193 37 196617 \$1 30;
#P newex 371 213 32 196617 line~;
#P newex 58 213 32 196617 line~;
#P hidden newex 29 18 48 196617 loadbang;
#P hidden message 29 39 26 196617 110;
#P comment 75 82 30 196617 Sync;
#P button 59 82 15 0;
#P user multiSlider 162 52 153 25 0. 1. 1 2680 47 0 0 9 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P newex 373 127 46 196617 phasor~;
#P flonum 200 277 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 409 104 17 196617 0.5;
#P newex 343 234 39 196617 *~ 0.2;
#P newex 343 147 40 196617 cycle~;
#B color 5;
#P newex 59 172 30 196617 !- 1.;
#P user ezdac~ 159 328 203 361 0;
#P newex 159 278 39 196617 *~ 0.2;
#P flonum 29 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 59 129 17 196617 0.;
#P newex 29 234 39 196617 *~ 0.2;
#P newex 29 147 40 196617 cycle~;
#B color 5;
#P comment 67 58 30 196617 Freq;
#P comment 160 37 35 196617 Cycle;
#P connect 5 0 2 0;
#P fasten 5 0 13 0 34 115 378 115;
#P connect 14 0 8 0;
#P connect 14 0 22 0;
#P connect 22 0 20 0;
#P connect 21 0 19 0;
#P connect 8 0 21 0;
#P connect 20 0 10 1;
#P connect 19 0 3 1;
#P connect 15 0 4 0;
#P fasten 15 0 11 0 64 102 414 102;
#P hidden connect 18 0 17 0;
#P hidden connect 17 0 5 0;
#P connect 4 0 2 1;
#P connect 2 0 3 0;
#P connect 11 0 13 1;
#P connect 13 0 9 1;
#P connect 9 0 10 0;
#P connect 12 0 6 1;
#P connect 10 0 6 0;
#P connect 3 0 6 0;
#P connect 6 0 7 0;
#P connect 6 0 7 1;
#P window clipboard copycount 25;

Chris Muir
cbm@well.com