Hi!
Is there some way to fill an array (table) with an arbitrary wave form programatically? I know I can use sinesum or cosinesum to generate sums of sinusoidal wave forms, and in theory any periodic waveform can be generated this way. But I want to generate wave forms using more complicated trigonometric expressions, for example sin(sin(x) * pi) or sin(x) ^ 3. I'm not sure what they would sound like (which is what motivates me to try), or if there's some way to transform these expressions to use only sinesum or cosinesum (my knowledge of math is somewhat limited).
Any suggestions on how I could do that in Pure Data? I could create an audio file using some other software tool and then load it into Pure Data, but I'd like to know if there's some way to do it directly in PD.
Thanks.
just
think of the table size you want.
get its period in seconds, or better, its frequency, according to the
sample rate
careful to set the starting phase as zero, as well)
into, like sin(sin(x) * pi) or sin(x) ^ 3, put that into an [expr~]
there you go
2014-04-08 21:41 GMT-03:00 David dfkettle@gmail.com:
Hi!
Is there some way to fill an array (table) with an arbitrary wave form programatically? I know I can use sinesum or cosinesum to generate sums of sinusoidal wave forms, and in theory any periodic waveform can be generated this way. But I want to generate wave forms using more complicated trigonometric expressions, for example sin(sin(x) * pi) or sin(x) ^ 3. I'm not sure what they would sound like (which is what motivates me to try), or if there's some way to transform these expressions to use only sinesum or cosinesum (my knowledge of math is somewhat limited).
Any suggestions on how I could do that in Pure Data? I could create an audio file using some other software tool and then load it into Pure Data, but I'd like to know if there's some way to do it directly in PD.
Thanks.
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
On 2014-04-09 02:41, David wrote:
Any suggestions on how I could do that in Pure Data?
[loadbang] | [1024( | [t f f| | [; mytable resize $1( | [until] | | +---+ [i -1] | [+ 1] | [t f f] | | +--+ | [t f f] | | [/ 1024] | [* 3.141592654] | [/ 180] | | | [sin] | | | [t b f] | | | | [random 101] | | [- 50] | | [/ 500] | | | | | [+ ] | | | [tabwrite mytable]
I don't know if it's exactly what you had in mind, but here's an example with expr gr, Tim
2014-04-09 9:46 GMT+02:00 IOhannes m zmoelnig zmoelnig@iem.at:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
On 2014-04-09 02:41, David wrote:
Any suggestions on how I could do that in Pure Data?
[loadbang] | [1024( | [t f f| | [; mytable resize $1( | [until] | | +---+ [i -1] | [+ 1] | [t f f] | | +--+ | [t f f] | | [/ 1024] | [* 3.141592654] | [/ 180] | | | [sin] | | | [t b f] | | | | [random 101] | | [- 50] | | [/ 500] | | | | | [+ ] | | | [tabwrite mytable] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Using GnuPG with Icedove - http://www.enigmail.net/
iQIcBAEBCAAGBQJTRPrVAAoJELZQGcR/ejb4ki8P/15TNi3xkzzFi9yQ6PGDq8ik EEgoQnDlLvr7yxuBe5+Cx3ZbgWiSN1bnHUnyjmbnz7xW3m8hdO0TjYH4q1OsZhGT ng7+HlWStgAzla5AMDC0zo7FOYPlOT6fh7CaugADoBg2yiFHLkj6e2Qo6XZxk+D6 ktaBU0tnIHa2xVwc77zRHVr8zSqL5fRArPy9DUq6ElB3FeAw+L9kv9/Dz+AqvPeK hNWSqsIf2vJr4VeufAiAGlRfFRzWUtTQW4rntwktYDyz6u6BX7WowqA0cmDRfwce SmHNnl3kSTvZMfeMEcIbwh0NxZ0CkWbm6xULHkEN/vt2CPjjS5hhl7hk3Pf5YgtV VOjMCDr200FkDjepkjbzKAC8HbiHFZk1voe6v1AJhB2mo1GkL9KD1gKhzRMqnU4j VqCO3bK1+ikGQdWrVKs3vcIeYHlVtjWRGTdSmcGSCBJS+3JnHRWkMDhmE8xfpmbC VZnf6cJP/dU0joEypeH8Rklj8gWq3O/SO5go4els86xcxFG84uWB3Pux6e0SbNG3 kZKx8zyUIonhMHamuGcVhfu617O9RYS8IEno2OFuaTUoOrM4mwEMKAekb0sRMVGM IWonEwNTPZIuErREhRB1sOsMGXE+LtVEj3LurS8D34fafXOxyFPjThC7bcYySkP9 R4egh1HAlBIx+YteH7HZ =kKlk -----END PGP SIGNATURE-----
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On 04/09/2014 09:46 AM, IOhannes m zmoelnig wrote:
[sin] |
ah, there is no [sin] object, use [cos] instead.
anyhow, the patch was not really meant to be be copied to your Pd instance, but to show how easy it is to do what you want.
it basically consists of two three parts: #1 generate numbers 0..1023; i'm using [until] and a counter for this. for simplicity, the counter is not reset at the beginning, so it will only generate the correct numbers once (the next time you click on [1024(, it will instead generate numbers 1024..2047); adding a reset is simple enough.
#2 normalize the numbers 0..1023 to something more useful, e.g. to 0..2pi (my code is bogus here, as it incorporates a deg2rad conversion without ever seeing deg values) and use these values as input to a function (in my example sin(x)+0.1*random())
#3 write the generated value into the table at the given index (the value from the counter)
fgmrdsa IOhannes
hey, I tried making mine a bit more understandable
it works with any table size. Just set the size as the argument in the [table] object.
This means it works with [tabosc4~] if you'd like, and it makes the extra 3 guard points correctively.
The guard points thing and interpolation is a bit hard to grasp at first. Say you have 0-96 points, you need extra 3 points (1 in the beggining, 2 at the end) so it goes now from 0-99 and your original indexes are now from *1 to 97*. The first point (0) needs to be equal to the last one (97) and then the extra two points (98-99) must be equal to (1-2).
What my patch does is get the table size and consider it has these extra points, so it writes the table values like sinesum does.
In the example I'm doing a hann window and using it as an envelope, but you could do whatever.
cheers
2014-04-10 8:45 GMT-03:00 IOhannes m zmölnig zmoelnig@iem.at:
On 04/09/2014 09:46 AM, IOhannes m zmoelnig wrote:
[sin] |
ah, there is no [sin] object, use [cos] instead.
anyhow, the patch was not really meant to be be copied to your Pd instance, but to show how easy it is to do what you want.
it basically consists of two three parts: #1 generate numbers 0..1023; i'm using [until] and a counter for this. for simplicity, the counter is not reset at the beginning, so it will only generate the correct numbers once (the next time you click on [1024(, it will instead generate numbers 1024..2047); adding a reset is simple enough.
#2 normalize the numbers 0..1023 to something more useful, e.g. to 0..2pi (my code is bogus here, as it incorporates a deg2rad conversion without ever seeing deg values) and use these values as input to a function (in my example sin(x)+0.1*random())
#3 write the generated value into the table at the given index (the value from the counter)
fgmrdsa IOhannes
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list