Author |
Message |
moudi
Joined: Oct 07, 2006 Posts: 63 Location: Bern Switzerland
|
Posted: Tue Nov 07, 2006 2:36 pm Post subject:
Cast from dur to int? Subject description: struggling with SndBuf |
|
|
hi all
I'm doing some stuff with SndBuf and now i wonder how i can start the sample with a specific duaration offset.
eg: play the wav from pos(44100), this means it starts at 0:01.000 (if the wav is recorded with 44.1).
since the .pos and .samples parameters are integers i need somehow to convert the duration to an integer wich represents the count of samples.
i didn't find any functions in the std package nor works the casting operator $ for this kind of data (wich seems logical to me).
so, has anybody a good idea how to do that or knows some "special hidden feature " wich can help me?
im thankful for every hint.
(probably i'm outing me as the biggest newbie ever )
/moudi |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24081 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Tue Nov 07, 2006 2:42 pm Post subject:
Re: Cast from dur to int? Subject description: struggling with SndBuf |
|
|
moudi wrote: |
(probably i'm outing me as the biggest newbie ever |
Guess not
http://electro-music.com/forum/topic-14239.html , that's what you meant right ? _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Tue Nov 07, 2006 3:06 pm Post subject:
|
|
|
I think so but this is a slightly different problem then just pure conversion of dur to int.
As soon as you are dealing with SndBuf you need to talk about "samples" from the perspective of the buffer. Exactly how long such a sample "lasts" depends on the playback rate of the buffer.
So; if your playback rate is two you should multiply your amount of samples that you start at by .5 if you want to stay consistent with regard to the time skipped by the buffer (meaning you will start at a different point in the wave...). The buffer can run in reverse too, sadly that doesn't give you negative time
It's takes a bit of thought but it's quite powerfull and the math is very simple.
I think it's best to calculate your sample rate at the top of the file if you want to refer to samp as a duration, BTW. This allows you to make programs that keep playing nicely if you are later forced to reduce ChucK's sample rate because of cpu limitations. _________________ Kassen |
|
Back to top
|
|
|
moudi
Joined: Oct 07, 2006 Posts: 63 Location: Bern Switzerland
|
Posted: Tue Nov 07, 2006 4:41 pm Post subject:
Re: Cast from dur to int? Subject description: struggling with SndBuf |
|
|
OMG, it looks like i'll have to use the search function before i'll post some sh*t next time !
thanks a lot for your kindly patience with me, i think i got it now.
/moudi |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24081 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Tue Nov 07, 2006 6:06 pm Post subject:
Re: Cast from dur to int? Subject description: struggling with SndBuf |
|
|
moudi wrote: | OMG, it looks like i'll have to use the search function before i'll post some sh*t next time ! |
I can desorient the sheer imagedness off the forum comprehended, sight on first. Madness, and it goes on (there are hours for that). Read all is best, and remember. 1
So that's all quite understandable
Quote: | i think i got it now.i |
Tthat's a good thing (be sure though to go into Kassen's details as well)
1 : sorry, must have been programming a bit too much today, or something, promise I 'll get some sleep now, erm, soon. _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Wed Nov 08, 2006 7:00 am Post subject:
|
|
|
Except that there is a bit of a error in my notre; if you play the buffer twice as fast a second will of cource take twice as many samples (of the buffer) not .5
Silly me.
The rest stands; a sample's duration of the buffer is a variable unit of time which is good and powerfull but needs care or it'll sound out of sync. _________________ Kassen |
|
Back to top
|
|
|
|