zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit c5e5c3b2efa0a8e2d1fef23294d4a2af21f640e9
parent 0b0b236677c3d2456f8e8200f23fd7f4505a01c5
Author: paulnasca <paulnasca>
Date:   Thu, 25 Mar 2004 19:06:16 +0000

*** empty log message ***

Diffstat:
MChangeLog | 2+-
Mexamples/Split_keyboard.mas_zyn | 0
Msrc/Seq/MIDIFile.C | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/Seq/MIDIFile.h | 9+++++++++
4 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog @@ -561,6 +561,6 @@ 15 Mar 2004 - Inceput sa scriu partea de incarcare MIDI - Inlaturata partea de recording din Sequencer 16 Mar 2004 - Inceput sa scriu partea de analiza midi - +25 Mar 2004 - Continuat partea de analiza midi diff --git a/examples/Split_keyboard.mas_zyn b/examples/Split_keyboard.mas_zyn Binary files differ. diff --git a/src/Seq/MIDIFile.C b/src/Seq/MIDIFile.C @@ -80,9 +80,57 @@ int MIDIFile::parsemidifile(){ int format=getint16(); printf("format %d\n",format); + int ntracks=getint16();//this is always if the format is "0" + printf("ntracks %d\n",ntracks); + + if (ntracks>=NUM_MIDI_CHANNELS){ + ntracks=NUM_MIDI_CHANNELS; + }; + + int division=getint16(); + printf("division %d\n",division); + if (division>=0){//delta time units in each a quater note +// tick=???; + } else {//SMPTE (frames/second and ticks/frame) + printf("ERROR:in MIDIFile.C::parsemidifile() - SMPTE not implemented yet."); + }; + +// for (int n=0;n<ntracks;n++){ + if (parsetrack(0)<0) { + clearmidifile(); + return(-1); + }; +// }; + return(0); }; +int MIDIFile::parsetrack(int ntrack){ + printf("\n--==*Reading track %d **==--\n",ntrack); + + int chunk=getint32();//MTrk + if (chunk!=0x4d54726b) return(-1); + + int size=getint32(); + printf("%d\n",size); +// if (size!=6) return(-1);//header is always 6 bytes long +/* +unsigned long ReadVarLen( void ) { + unsigned long value; + byte c; + + if ((value = getc(infile)) & 0x80) { + value &= 0x7f; + do { + value = (value << 7) + ((c = getc(infile)) & 0x7f); + } while (c & 0x80); + } + return value; +} + +*/ +}; + //private members void MIDIFile::clearmidifile(){ @@ -91,6 +139,9 @@ void MIDIFile::clearmidifile(){ midifilesize=0; midifilek=0; midieof=false; + + data.tick=0.05; + }; unsigned char MIDIFile::getbyte(){ diff --git a/src/Seq/MIDIFile.h b/src/Seq/MIDIFile.h @@ -23,6 +23,8 @@ #ifndef MIDIFILE_H #define MIDIFILE_H +#include "../globals.h" + class MIDIFile{ public: MIDIFile(); @@ -34,6 +36,9 @@ class MIDIFile{ //returns -1 if there is an error, otherwise 0 int parsemidifile(); + //returns -1 if there is an error, otherwise 0 + int parsetrack(int ntrack); + private: unsigned char *midifile; int midifilesize,midifilek; @@ -50,6 +55,10 @@ class MIDIFile{ //get a word of 2 bytes from the midifile unsigned short int getint16(); + struct { + double tick;//how many seconds one tick has + }data; + }; #endif