diff options
Diffstat (limited to 'apps/plugins/midi/midiutil.c')
-rw-r--r-- | apps/plugins/midi/midiutil.c | 118 |
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 | ||
65 | extern struct plugin_api * rb; | 22 | extern struct plugin_api * rb; |
66 | 23 | ||
67 | int printf(const char *fmt, ...); | ||
68 | |||
69 | int chVol[16] IBSS_ATTR; /* Channel volume */ | 24 | int chVol[16] IBSS_ATTR; /* Channel volume */ |
70 | int chPanLeft[16] IBSS_ATTR; /* Channel panning */ | 25 | int chPanLeft[16] IBSS_ATTR; /* Channel panning */ |
71 | int chPanRight[16] IBSS_ATTR; | 26 | int chPanRight[16] IBSS_ATTR; |
72 | int chPat[16] IBSS_ATTR; /* Channel patch */ | 27 | int chPat[16] IBSS_ATTR; /* Channel patch */ |
73 | int chPW[16] IBSS_ATTR; /* Channel pitch wheel, MSB only */ | 28 | int chPW[16] IBSS_ATTR; /* Channel pitch wheel, MSB only */ |
74 | 29 | ||
75 | |||
76 | struct GPatch * gusload(char *); | 30 | struct GPatch * gusload(char *); |
77 | struct GPatch * patchSet[128]; | 31 | struct GPatch * patchSet[128]; |
78 | struct GPatch * drumSet[128]; | 32 | struct GPatch * drumSet[128]; |
79 | 33 | ||
80 | struct Event | ||
81 | { | ||
82 | unsigned int delta; | ||
83 | unsigned char status, d1, d2; | ||
84 | unsigned int len; | ||
85 | unsigned char * evData; | ||
86 | }; | ||
87 | |||
88 | struct 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 | |||
98 | struct 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 | /* | ||
109 | struct 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 | |||
122 | struct 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 | |||
135 | struct SynthObject voices[MAX_VOICES] IBSS_ATTR; | 34 | struct SynthObject voices[MAX_VOICES] IBSS_ATTR; |
136 | 35 | ||
137 | void sendEvent(struct Event * ev); | ||
138 | inline void setPoint(struct SynthObject * so, int pt); | ||
139 | struct Event * getEvent(struct Track * tr, int evNum); | ||
140 | int readTwoBytes(int file); | ||
141 | int readFourBytes(int file); | ||
142 | int readVarData(int file); | ||
143 | int midimain(void * filename); | ||
144 | |||
145 | |||
146 | void *alloc(int size) | 36 | void *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 | /* |
186 | void *alloc(int size) | 75 | void *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 | |||