Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Play samples at different pitches by MIDI

  1. #1
    Junior Member
    Join Date
    Jan 2016

    Play samples at different pitches by MIDI


    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

  2. #2
    For pitched playback, check out the thread where they were discussing granular playback. It's not exactly an easy problem to solve.

    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.

  3. #3
    Junior Member
    Join Date
    Jan 2018
    Hi all,
    I was searching for the same and did not want to use an extra granular playback.

    With my solution, the play_wav_sd.cpp and play_wav_sd.h are changed and use SDFAT-Lib to be able to read other filenames.
    They got an extra attribute to change the pitch defined in float. 1.0 = same speed, 2.0 = double speed, 0.5 = halve speed. The last limitation was 4.0 on upper and 0.25 on the lower side.

    I hope it works in future projects.

    Take it as an adventure and explore it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts