PDA

View Full Version : Play samples at different pitches by MIDI



localhero
03-18-2016, 05:56 PM
Hi,

Today I've mounted the audio board on the Teensy 3.2 that I have received.
After having tried some skecth examples everything seems to be working fine.

Now my project is to build a small MIDI sampler, let's say a MIDI instrument that plays/records samples.
So from the example sketch I know I can play samples at their origin speed (or pitch), now I would like to go further and trigger samples by playing notes by MIDI on my master keyboard.
And of course I would like to be able to play a sample on different notes (at different speeds). The AudioPlaySdWav object has a "play" method, is there a way to change the pitch ?
Let's say by assigning a root note (for the origin speed), for example C3 and then change the pitch according to the MIDI note received.

It would be great to be able to loop a sample too :)

Noob question : what is controlling the optional pot ? I've soldered one but it doesn't adjust the volume level on the minijack output (level which is set in the sketch, that could explain)

Thanks and regards
David

B.Jacquot
03-18-2016, 08:43 PM
For pitched playback, check out the thread where they were discussing granular playback. It's not exactly an easy problem to solve.

https://forum.pjrc.com/threads/29275-Granular-Synthesis-with-Teensy-and-Audio-Adaptor

The pot is tied to A1. Your sketch can read it, and apply it to whatever parameter you wish. For a volume control on the Audio Adapter, do an analogRead(A1), then translate the result to a float and feed it to the sgtl5000.volume() method.