c standard midi file type-0 reader built for teensy (32 bit arm cortex m7 thumb arch
)
midireader reader;
reader.open("1234.mid");
double microsPerTick = reader.get_microseconds_per_tick();
int totalNumNotesRead = 0;
for (int t = 0; t < reader.getNumTracks(); t ) {
reader.setTrackNumber(t);
int i = 0;
long totalTicks = 0, microseconds = 0;
smfmidimessage *message;
while ((message = reader.read()) != nullptr) {
totalTicks = message->delta_ticks;
microseconds = microsPerTick * message->delta_ticks;
switch(message->getMessageType()) {
case smftype_channelvoicemessage : {
smfchannelvoicemessage *channelvoicemessage = (smfchannelvoicemessage *)message;
printf("]: [-,M]: m: delta: =\tstatus: 0x%2x\tdata1: =\tdata2: =\tdata3: -\t\n",
microseconds/1000,
t,
i,
totalTicks,
channelvoicemessage->delta_ticks,
channelvoicemessage->status,
channelvoicemessage->data1,
channelvoicemessage->data2,
channelvoicemessage->data3);
break;
}
case smftype_settempomessage : {
printf("tempo change: %f\n", ((smfsettempomessage *)message)->getTempo());
break;
}
default:
break;
}
delete message;
i ;
}
totalNumNotesRead = i;
}
-
src (
32 bit arm cortex m7 thumb arch
) -
tests (
amd64 arch
)- teensy_x86_stubs
git clone https://github.com/newdigate/teensy-x86-stubs.git cd teensy-x86-stubs mkdir cmake-build-debug cd cmake-build-debug cmake .. sudo make install
- libboost-test-dev
sudo apt-get update && sudo apt-get install -yq libboost-test-dev
- teensy_x86_stubs
- download gcc-arm-none-eabi
- clone src dependencies into a directory (in this case
/Users/me/git
)
mkdir /Users/me/git
cd /Users/me/git
git clone https://github.com/PaulStoffregen/cores
git clone https://github.com/greiman/SdFat
git clone -b Juse_Use_SdFat https://github.com/PaulStoffregen/SD
git clone https://github.com/PaulStoffregen/SPI
- update COMPILERPATH, DEPSPATH in
cmake/toolchains/teensy41.toolchain.cmake:
set(COMPILERPATH "/Applications/ARM/bin/") # should point to folder with GCC-ARM-NONE-EABI executables
set(DEPSPATH "/Users/me/git") # path with 4 x src dependencies
- run these commands in a terminal from the root repository directory
mkdir cmake-build-debug
cd cmake-build-debug
cmake .. -DCMAKE_TOOLCHAIN_FILE:FILEPATH="../cmake/toolchains/teensy41.toolchain.cmake"
make
- clone:
git clone https://github.com/newdigate/midi-smf-reader.git cd midi-smf-reader
- compile src, tests
mkdir cmake-build-debug cd cmake-build-debug cmake .. make
- run tests
test/midi_smf_reader_test
- install library for linux:
sudo make install
- uninstall library for linux:
sudo make uninstall
read tempo / key changesdone
- stackoverflow 11437456
- includes code from IronSavior/dsm2_tx
Unless specified in source code file, all code is MIT license.