summaryrefslogtreecommitdiff
path: root/apps/plugins/midi/midiutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/midi/midiutil.c')
-rw-r--r--apps/plugins/midi/midiutil.c118
1 files changed, 4 insertions, 114 deletions
diff --git a/apps/plugins/midi/midiutil.c b/apps/plugins/midi/midiutil.c
index 0607c1ab3c..7cb128fb84 100644
--- a/apps/plugins/midi/midiutil.c
+++ b/apps/plugins/midi/midiutil.c
@@ -5,6 +5,7 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$
8 * 9 *
9 * Copyright (C) 2005 Stepan Moskovchenko 10 * Copyright (C) 2005 Stepan Moskovchenko
10 * 11 *
@@ -15,134 +16,23 @@
15 * KIND, either express or implied. 16 * KIND, either express or implied.
16 * 17 *
17 ****************************************************************************/ 18 ****************************************************************************/
18 19#include "plugin.h"
19 20#include "midiutil.h"
20#define BYTE unsigned char
21
22//Data chunk ID types, returned by readID()
23#define ID_UNKNOWN -1
24#define ID_MTHD 1
25#define ID_MTRK 2
26#define ID_EOF 3
27#define ID_RIFF 4
28
29
30//MIDI Commands
31#define MIDI_NOTE_OFF 128
32#define MIDI_NOTE_ON 144
33#define MIDI_AFTERTOUCH 160
34#define MIDI_CONTROL 176
35#define MIDI_PRGM 192
36#define MIDI_PITCHW 224
37
38
39//MIDI Controllers
40#define CTRL_VOLUME 7
41#define CTRL_BALANCE 8
42#define CTRL_PANNING 10
43#define CHANNEL 1
44
45//Most of these are deprecated.. rampdown is used, maybe one other one too
46#define STATE_ATTACK 1
47#define STATE_DECAY 2
48#define STATE_SUSTAIN 3
49#define STATE_RELEASE 4
50#define STATE_RAMPDOWN 5
51
52//Loop states
53#define STATE_LOOPING 7
54#define STATE_NONLOOPING 8
55
56//Various bits in the GUS mode byte
57#define LOOP_ENABLED 4
58#define LOOP_PINGPONG 8
59#define LOOP_REVERSE 16
60
61#define LOOPDIR_FORWARD 0
62#define LOOPDIR_REVERSE 1
63
64 21
65extern struct plugin_api * rb; 22extern struct plugin_api * rb;
66 23
67int printf(const char *fmt, ...);
68
69int chVol[16] IBSS_ATTR; /* Channel volume */ 24int chVol[16] IBSS_ATTR; /* Channel volume */
70int chPanLeft[16] IBSS_ATTR; /* Channel panning */ 25int chPanLeft[16] IBSS_ATTR; /* Channel panning */
71int chPanRight[16] IBSS_ATTR; 26int chPanRight[16] IBSS_ATTR;
72int chPat[16] IBSS_ATTR; /* Channel patch */ 27int chPat[16] IBSS_ATTR; /* Channel patch */
73int chPW[16] IBSS_ATTR; /* Channel pitch wheel, MSB only */ 28int chPW[16] IBSS_ATTR; /* Channel pitch wheel, MSB only */
74 29
75
76struct GPatch * gusload(char *); 30struct GPatch * gusload(char *);
77struct GPatch * patchSet[128]; 31struct GPatch * patchSet[128];
78struct GPatch * drumSet[128]; 32struct GPatch * drumSet[128];
79 33
80struct Event
81{
82 unsigned int delta;
83 unsigned char status, d1, d2;
84 unsigned int len;
85 unsigned char * evData;
86};
87
88struct Track
89{
90 unsigned int size;
91 unsigned int numEvents;
92 unsigned int delta; /* For sequencing */
93 unsigned int pos; /* For sequencing */
94 void * dataBlock;
95};
96
97
98struct MIDIfile
99{
100 int Length;
101 unsigned short numTracks;
102 unsigned short div; /* Time division, X ticks per millisecond */
103 struct Track * tracks[48];
104 unsigned char patches[128];
105 int numPatches;
106};
107
108/*
109struct SynthObject
110{
111 struct GWaveform * wf;
112 unsigned int delta;
113 unsigned int decay;
114 unsigned int cp;
115 unsigned char state, loopState, loopDir;
116 unsigned char note, vol, ch, isUsed;
117 int curRate, curOffset, targetOffset;
118 unsigned int curPoint;
119};
120*/
121
122struct SynthObject
123{
124 struct GWaveform * wf;
125 int delta;
126 int decay;
127 unsigned int cp; /* unsigned int */
128 int state, loopState, loopDir;
129 int note, vol, ch, isUsed;
130 int curRate, curOffset, targetOffset;
131 int curPoint;
132 signed short int volscale;
133};
134
135struct SynthObject voices[MAX_VOICES] IBSS_ATTR; 34struct SynthObject voices[MAX_VOICES] IBSS_ATTR;
136 35
137void sendEvent(struct Event * ev);
138inline void setPoint(struct SynthObject * so, int pt);
139struct Event * getEvent(struct Track * tr, int evNum);
140int readTwoBytes(int file);
141int readFourBytes(int file);
142int readVarData(int file);
143int midimain(void * filename);
144
145
146void *alloc(int size) 36void *alloc(int size)
147{ 37{
148 static char *offset = NULL; 38 static char *offset = NULL;
@@ -180,7 +70,6 @@ void *alloc(int size)
180 return ret; 70 return ret;
181} 71}
182 72
183
184/* Rick's code */ 73/* Rick's code */
185/* 74/*
186void *alloc(int size) 75void *alloc(int size)
@@ -267,3 +156,4 @@ void exit(int code)
267{ 156{
268 code = code; /* Stub function, kill warning for now */ 157 code = code; /* Stub function, kill warning for now */
269} 158}
159