Mercurial > hg > forks > bilotrip-mj12
view src/midifile.h @ 34:a14cc6c5d7ef
Possibly fix 64-bit issues. Probably not.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 05 Aug 2013 20:51:20 +0300 |
parents | 785057719d9b |
children | 1db62040204e |
line wrap: on
line source
#ifndef _MIDIFILE_H #define _MIDIFILE_H #include "midiinfo.h" /* enumerations and constants for GM */ #include "mtypes.h" /* * midiFile.c - Header file for Steevs MIDI Library * Version 1.4 * * AUTHOR: Steven Goodwin (StevenGoodwin@gmail.com) * Copyright 1998-2010, Steven Goodwin. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License,or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* ** All functions start with one of the following prefixes: ** midiFile* For non-GM features that relate to the file, and have ** no use once the file has been created, i.e. CreateFile ** or SetTrack (those data is embedded into the file, but ** not explicitly stored) ** midiSong* For operations that work across the song, i.e. SetTempo ** midiTrack* For operations on a specific track, i.e. AddNoteOn */ /* ** MIDI Constants */ #define MIDI_PPQN_DEFAULT 384 #define MIDI_VERSION_DEFAULT 1 /* ** MIDI Limits */ #define MAX_MIDI_TRACKS 256 #define MAX_TRACK_POLYPHONY 64 /* ** MIDI structures, accessibly externably */ typedef void MIDI_FILE; typedef struct { tMIDI_MSG iType; Uint32 dt; /* delta time */ Uint32 dwAbsPos; Uint32 iMsgSize; BOOL bImpliedMsg; tMIDI_MSG iImpliedMsg; /* Raw data chunk */ Uint8 *data; /* dynamic data block */ Uint32 data_sz; union { struct { int iNote; int iChannel; int iVolume; } NoteOn; struct { int iNote; int iChannel; } NoteOff; struct { int iNote; int iChannel; int iPressure; } NoteKeyPressure; struct { int iChannel; tMIDI_CC iControl; int iParam; } NoteParameter; struct { int iChannel; int iProgram; } ChangeProgram; struct { int iChannel; int iPressure; } ChangePressure; struct { int iChannel; int iPitch; } PitchWheel; struct { tMIDI_META iType; union { int iMIDIPort; int iSequenceNumber; struct { Uint8 *pData; } Text; struct { int iBPM; } Tempo; struct { int iHours, iMins; int iSecs, iFrames, iFF; } SMPTE; struct { tMIDI_KEYSIG iKey; } KeySig; struct { int iNom, iDenom; } TimeSig; struct { Uint8 *pData; int iSize; } Sequencer; } Data; } MetaEvent; struct { Uint8 *pData; int iSize; } SysEx; } MsgData; /* State information - Please treat these as private */ tMIDI_MSG iLastMsgType; Uint8 iLastMsgChnl; } MIDI_MSG; /* ** midiFile* Prototypes */ MIDI_FILE *midiFileCreate(const char *pFilename, BOOL bOverwriteIfExists); int midiFileSetTracksDefaultChannel(MIDI_FILE *pMF, int iTrack, int iChannel); int midiFileGetTracksDefaultChannel(const MIDI_FILE *pMF, int iTrack); BOOL midiFileFlushTrack(MIDI_FILE *pMF, int iTrack, BOOL bFlushToEnd, Uint32 dwEndTimePos); BOOL midiFileSyncTracks(MIDI_FILE *pMF, int iTrack1, int iTrack2); int midiFileSetPPQN(MIDI_FILE *pMF, int PPQN); int midiFileGetPPQN(const MIDI_FILE *pMF); int midiFileSetVersion(MIDI_FILE *pMF, int iVersion); int midiFileGetVersion(const MIDI_FILE *pMF); MIDI_FILE *midiFileOpen(const char *pFilename); BOOL midiFileClose(MIDI_FILE *pMF); /* ** midiSong* Prototypes */ BOOL midiSongAddSMPTEOffset(MIDI_FILE *pMF, int iTrack, int iHours, int iMins, int iSecs, int iFrames, int iFFrames); BOOL midiSongAddSimpleTimeSig(MIDI_FILE *pMF, int iTrack, int iNom, int iDenom); BOOL midiSongAddTimeSig(MIDI_FILE *pMF, int iTrack, int iNom, int iDenom, int iClockInMetroTick, int iNotated32nds); BOOL midiSongAddKeySig(MIDI_FILE *pMF, int iTrack, tMIDI_KEYSIG iKey); BOOL midiSongAddTempo(MIDI_FILE *pMF, int iTrack, int iTempo); BOOL midiSongAddMIDIPort(MIDI_FILE *pMF, int iTrack, int iPort); BOOL midiSongAddEndSequence(MIDI_FILE *pMF, int iTrack); /* ** midiTrack* Prototypes */ BOOL midiTrackAddRaw(MIDI_FILE *pMF, int iTrack, int iDataSize, const Uint8 * pData, BOOL bMovePtr, int iDeltaTime); BOOL midiTrackIncTime(MIDI_FILE *pMF, int iTrack, int iDeltaTime, BOOL bOverridePPQN); BOOL midiTrackAddText(MIDI_FILE *pMF, int iTrack, tMIDI_TEXT iType, const char *pTxt); BOOL midiTrackAddMsg(MIDI_FILE *pMF, int iTrack, tMIDI_MSG iMsg, int iParam1, int iParam2); BOOL midiTrackSetKeyPressure(MIDI_FILE *pMF, int iTrack, int iNote, int iAftertouch); BOOL midiTrackAddControlChange(MIDI_FILE *pMF, int iTrack, tMIDI_CC iCCType, int iParam); BOOL midiTrackAddProgramChange(MIDI_FILE *pMF, int iTrack, int iInstrPatch); BOOL midiTrackChangeKeyPressure(MIDI_FILE *pMF, int iTrack, int iDeltaPressure); BOOL midiTrackSetPitchWheel(MIDI_FILE *pMF, int iTrack, int iWheelPos); BOOL midiTrackAddNote(MIDI_FILE *pMF, int iTrack, int iNote, int iLength, int iVol, BOOL bAutoInc, BOOL bOverrideLength); BOOL midiTrackAddRest(MIDI_FILE *pMF, int iTrack, int iLength, BOOL bOverridePPQN); BOOL midiTrackGetEndPos(MIDI_FILE *pMF, int iTrack); /* ** midiRead* Prototypes */ int midiReadGetNumTracks(const MIDI_FILE *pMF); BOOL midiReadGetNextMessage(const MIDI_FILE *pMF, int iTrack, MIDI_MSG * pMsg); void midiReadInitMessage(MIDI_MSG * pMsg); void midiReadFreeMessage(MIDI_MSG * pMsg); #endif /* _MIDIFILE_H */