Yes, you can use pitch: or rpitch: when calling sample in your own function so that you can pass the function a note, and it works out the right pitch for the sample to play at. (The other topic I linked above - Tune samples with a note input shows an example: Robin’s :plAmbiChoir function there takes a note to play at, a note length, and a number representing the ratio between the note’s sustain and release values, for a basic sound envelope, and plays the sample at the correct pitch). I’m sure you could use a similar function with your own samples - you’d just need to work out the basic pitch of your un-modified sample, as Robin describes in his thread.
Feel free to have a go at adapting Robin’s example if you like - I’m happy to help you if you want.
2 Likes