Gen~ Sample playback pitch changes when sample rate changes

leafcutter's icon

leafcutter

6月 20 2024 | 8:37 午後

Maybe I've been spoiled by the usual max signal world taking care of sample rates so I can play a sound file at the correct pitch regardless of the sample rate.

I don't seem to be able to get gen~ to do this. Does the following patch display the expected behaviour? I could't find anything about it in the documentation.

Max Patch
Copy patch and select New From Clipboard in Max.

Cheers,

John.

Roman Thilenius's icon

Roman Thilenius

6月 20 2024 | 10:10 午後

because 0->groove can do it and gen~ [count]-[sample] not?
count~-index~ in MSP will also not auto adapt and play faster at 88 i am afraid.
i would use dspstate~ for both situations... and/or have a rate check indcluded whenever importing files... and in my eyes only the bevahiour of groove~ is a bit strange.

Max Gardener's icon

Max Gardener

6月 21 2024 | 4:53 午前

I'm not entirely certain I completely understand your question, so forgive me if I've got this wrong. I hope this helps to explain it a little. Roman's right about keeping track of the sample rate of any audio file you load. Happily, the info~ object lets you do that, so you've got a base to calculate your playback rates inside the gen~ object from.

Max Patch
Copy patch and select New From Clipboard in Max.

leafcutter's icon

leafcutter

6月 21 2024 | 7:47 午前

Ok, so yes it is the expected behaviour then. I just wanted to check.

Obviously it's not too hard to deal with tracking the sample rates of samples. But somewhat harder to deal with the embarrassment of playing around with Max 20+ years and never noticing this 😳

44.1 kHz till I die baby!

Roman Thilenius's icon

Roman Thilenius

6月 21 2024 | 3:16 午後

whenever rate comes to play, i use custom code instead of readymade solutions.

such functions will have a default variable or argument of "44100" somewhere, so that you can see at one glance that this means "rate" and is dependent on that.

when the patch must be ready for arbitrary rates, i later add an 110.sr (which is based on dspstate~) to overwrite that initial "44100" by a loadbang (which is not really needed because dspstate~ does that on its own, but i prefer to add one.)