Clear Filters
Clear Filters

Midi Keyboard using sound recordings?

3 views (last 30 days)
Joel Sieber
Joel Sieber on 24 Mar 2021
I am trying to implement a virtual pipe organ that is played in real-time using midi keyboards. When a note is pressed on a keyboard or clicked on the gui, a corresponding sound recording of the note should play on repeat, until the key is released. The start and end of each recording has been cut so that it can be looped seamlessly. I'm using MATLAB and Audio Toolbox. I've created the GUI using App Designer and it consists of state buttons for each key of the instrument.
Whether I use the deviceWriter or sound(y, Fs) functions, I can't get more than a single note to play without MATLAB freezing in what seems to be an infinite loop. I've tried:
  • Using the ValueChanged callback and having the file play while a key button's value is 1
  • Using regular buttons instead of statebuttons - clicking on these just plays the audio file for one iteration
  • Editing the simplesynth example at to play my sound file instead of a frequency - Sound plays once then seems to be stuck in an infinite loop
  • Using the playblocking function to play the sound - this doesn't cause the infinite loop but after each repeat of the sound file, there is a split-second pause where there is no sound
Is it possible to create a midi keyboard in matlab that plays sound files for each note, rather than just playing frequencies? If so, where am I going wrong? And if not, please could you point me in the right direction as to how I can implement a solution, perhaps using external plugins?

Answers (0)


Find more on Simulation, Tuning, and Visualization in Help Center and File Exchange




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!