summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/SDL_mixer/timidity
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/sdl/SDL_mixer/timidity')
-rw-r--r--apps/plugins/sdl/SDL_mixer/timidity/config.h6
-rw-r--r--apps/plugins/sdl/SDL_mixer/timidity/playmidi.c116
-rw-r--r--apps/plugins/sdl/SDL_mixer/timidity/readmidi.c59
-rw-r--r--apps/plugins/sdl/SDL_mixer/timidity/timidity.c23
4 files changed, 103 insertions, 101 deletions
diff --git a/apps/plugins/sdl/SDL_mixer/timidity/config.h b/apps/plugins/sdl/SDL_mixer/timidity/config.h
index 46f1aa95fe..32da0a8358 100644
--- a/apps/plugins/sdl/SDL_mixer/timidity/config.h
+++ b/apps/plugins/sdl/SDL_mixer/timidity/config.h
@@ -9,7 +9,9 @@
9/* This is for use with the SDL library */ 9/* This is for use with the SDL library */
10#ifndef __TIMIDITY_CONFIG_H__ 10#ifndef __TIMIDITY_CONFIG_H__
11#define __TIMIDITY_CONFIG_H__ 11#define __TIMIDITY_CONFIG_H__
12#ifndef SDL
12#define SDL 13#define SDL
14#endif
13#include "SDL_config.h" 15#include "SDL_config.h"
14#include "SDL_endian.h" 16#include "SDL_endian.h"
15 17
@@ -24,7 +26,7 @@
24#define DEFAULT_PROGRAM 0 26#define DEFAULT_PROGRAM 0
25 27
26/* 9 here is MIDI channel 10, which is the standard percussion channel. 28/* 9 here is MIDI channel 10, which is the standard percussion channel.
27 Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too. 29 Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too.
28 On the other hand, some files know that 16 is not a drum channel and 30 On the other hand, some files know that 16 is not a drum channel and
29 try to play music on it. This is now a runtime option, so this isn't 31 try to play music on it. This is now a runtime option, so this isn't
30 a critical choice anymore. */ 32 a critical choice anymore. */
@@ -131,7 +133,7 @@ typedef double FLOAT_T;
131#define MAX_CONTROL_RATIO 255 133#define MAX_CONTROL_RATIO 255
132 134
133typedef unsigned int uint32; 135typedef unsigned int uint32;
134typedef int int32; 136typedef int int32;
135typedef unsigned short uint16; 137typedef unsigned short uint16;
136typedef short int16; 138typedef short int16;
137typedef unsigned char uint8; 139typedef unsigned char uint8;
diff --git a/apps/plugins/sdl/SDL_mixer/timidity/playmidi.c b/apps/plugins/sdl/SDL_mixer/timidity/playmidi.c
index 84b18cf5cb..1638732dc5 100644
--- a/apps/plugins/sdl/SDL_mixer/timidity/playmidi.c
+++ b/apps/plugins/sdl/SDL_mixer/timidity/playmidi.c
@@ -6,9 +6,10 @@
6 it under the terms of the Perl Artistic License, available in COPYING. 6 it under the terms of the Perl Artistic License, available in COPYING.
7 */ 7 */
8 8
9#include "config.h"
10
9#include <SDL_rwops.h> 11#include <SDL_rwops.h>
10 12
11#include "config.h"
12#include "common.h" 13#include "common.h"
13#include "instrum.h" 14#include "instrum.h"
14#include "playmidi.h" 15#include "playmidi.h"
@@ -69,14 +70,14 @@ int XG_System_variation_type;
69 70
70 71
71static void adjust_amplification(void) 72static void adjust_amplification(void)
72{ 73{
73 master_volume = (FLOAT_T)(amplification) / (FLOAT_T)100.0; 74 master_volume = (FLOAT_T)(amplification) / (FLOAT_T)100.0;
74 master_volume /= 2; 75 master_volume /= 2;
75} 76}
76 77
77 78
78static void adjust_master_volume(int32 vol) 79static void adjust_master_volume(int32 vol)
79{ 80{
80 master_volume = (double)(vol*amplification) / 1638400.0L; 81 master_volume = (double)(vol*amplification) / 1638400.0L;
81 master_volume /= 2; 82 master_volume /= 2;
82} 83}
@@ -146,7 +147,7 @@ static void select_sample(int v, Instrument *ip)
146 } 147 }
147 148
148 f=voice[v].orig_frequency; 149 f=voice[v].orig_frequency;
149 /* 150 /*
150 No suitable sample found! We'll select the sample whose root 151 No suitable sample found! We'll select the sample whose root
151 frequency is closest to the one we want. (Actually we should 152 frequency is closest to the one we want. (Actually we should
152 probably convert the low, high, and root frequencies to MIDI note 153 probably convert the low, high, and root frequencies to MIDI note
@@ -214,11 +215,11 @@ static void select_stereo_samples(int v, InstrumentLayer *lp)
214 215
215static void recompute_freq(int v) 216static void recompute_freq(int v)
216{ 217{
217 int 218 int
218 sign=(voice[v].sample_increment < 0), /* for bidirectional loops */ 219 sign=(voice[v].sample_increment < 0), /* for bidirectional loops */
219 pb=channel[voice[v].channel].pitchbend; 220 pb=channel[voice[v].channel].pitchbend;
220 double a; 221 double a;
221 222
222 if (!voice[v].sample->sample_rate) 223 if (!voice[v].sample->sample_rate)
223 return; 224 return;
224 225
@@ -262,22 +263,22 @@ static void recompute_freq(int v)
262 (double)(play_mode->rate)), 263 (double)(play_mode->rate)),
263 FRACTION_BITS); 264 FRACTION_BITS);
264 265
265 if (sign) 266 if (sign)
266 a = -a; /* need to preserve the loop direction */ 267 a = -a; /* need to preserve the loop direction */
267 268
268 voice[v].sample_increment = (int32)(a); 269 voice[v].sample_increment = (int32)(a);
269} 270}
270 271
271static int expr_curve[128] = { 272static int expr_curve[128] = {
272 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 273 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11,
273 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 274 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15,
274 15, 16, 16, 17, 17, 17, 18, 18, 19, 19, 19, 20, 20, 21, 21, 22, 275 15, 16, 16, 17, 17, 17, 18, 18, 19, 19, 19, 20, 20, 21, 21, 22,
275 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 28, 28, 29, 30, 30, 31, 276 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 28, 28, 29, 30, 30, 31,
276 32, 32, 33, 34, 35, 35, 36, 37, 38, 39, 39, 40, 41, 42, 43, 44, 277 32, 32, 33, 34, 35, 35, 36, 37, 38, 39, 39, 40, 41, 42, 43, 44,
277 45, 46, 47, 48, 49, 50, 51, 53, 54, 55, 56, 57, 59, 60, 61, 63, 278 45, 46, 47, 48, 49, 50, 51, 53, 54, 55, 56, 57, 59, 60, 61, 63,
278 64, 65, 67, 68, 70, 71, 73, 75, 76, 78, 80, 82, 83, 85, 87, 89, 279 64, 65, 67, 68, 70, 71, 73, 75, 76, 78, 80, 82, 83, 85, 87, 89,
279 91, 93, 95, 97, 99, 102, 104, 106, 109, 111, 113, 116, 118, 121, 280 91, 93, 95, 97, 99, 102, 104, 106, 109, 111, 113, 116, 118, 121,
280 124, 127 281 124, 127
281}; 282};
282 283
283static int panf(int pan, int speaker, int separation) 284static int panf(int pan, int speaker, int separation)
@@ -423,7 +424,7 @@ static void recompute_amp(int v)
423/* just a variant of note_on() */ 424/* just a variant of note_on() */
424static int vc_alloc(int j) 425static int vc_alloc(int j)
425{ 426{
426 int i=voices; 427 int i=voices;
427 428
428 while (i--) 429 while (i--)
429 { 430 {
@@ -439,7 +440,7 @@ static void kill_note(int i);
439 440
440static void kill_others(int i) 441static void kill_others(int i)
441{ 442{
442 int j=voices; 443 int j=voices;
443 444
444 if (!voice[i].sample->exclusiveClass) return; 445 if (!voice[i].sample->exclusiveClass) return;
445 446
@@ -769,7 +770,7 @@ static void start_note(MidiEvent *e, int i)
769 ip = lp->instrument; 770 ip = lp->instrument;
770 if (ip->type == INST_GUS && ip->samples != 1) 771 if (ip->type == INST_GUS && ip->samples != 1)
771 { 772 {
772 ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, 773 ctl->cmsg(CMSG_WARNING, VERB_VERBOSE,
773 "Strange: percussion instrument with %d samples!", ip->samples); 774 "Strange: percussion instrument with %d samples!", ip->samples);
774 } 775 }
775 776
@@ -989,14 +990,14 @@ static void kill_note(int i)
989/* Only one instance of a note can be playing on a single channel. */ 990/* Only one instance of a note can be playing on a single channel. */
990static void note_on(MidiEvent *e) 991static void note_on(MidiEvent *e)
991{ 992{
992 int i=voices, lowest=-1; 993 int i=voices, lowest=-1;
993 int32 lv=0x7FFFFFFF, v; 994 int32 lv=0x7FFFFFFF, v;
994 995
995 while (i--) 996 while (i--)
996 { 997 {
997 if (voice[i].status == VOICE_FREE) 998 if (voice[i].status == VOICE_FREE)
998 lowest=i; /* Can't get a lower volume than silence */ 999 lowest=i; /* Can't get a lower volume than silence */
999 else if (voice[i].channel==e->channel && 1000 else if (voice[i].channel==e->channel &&
1000 (voice[i].note==e->a || channel[voice[i].channel].mono)) 1001 (voice[i].note==e->a || channel[voice[i].channel].mono))
1001 kill_note(i); 1002 kill_note(i);
1002 } 1003 }
@@ -1007,7 +1008,7 @@ static void note_on(MidiEvent *e)
1007 start_note(e,lowest); 1008 start_note(e,lowest);
1008 return; 1009 return;
1009 } 1010 }
1010 1011
1011#if 0 1012#if 0
1012 /* Look for the decaying note with the lowest volume */ 1013 /* Look for the decaying note with the lowest volume */
1013 i=voices; 1014 i=voices;
@@ -1136,7 +1137,7 @@ static void all_notes_off(int c)
1136 if (voice[i].status==VOICE_ON && 1137 if (voice[i].status==VOICE_ON &&
1137 voice[i].channel==c) 1138 voice[i].channel==c)
1138 { 1139 {
1139 if (channel[c].sustain) 1140 if (channel[c].sustain)
1140 { 1141 {
1141 voice[i].status=VOICE_SUSTAINED; 1142 voice[i].status=VOICE_SUSTAINED;
1142 ctl->note(i); 1143 ctl->note(i);
@@ -1151,7 +1152,7 @@ static void all_sounds_off(int c)
1151{ 1152{
1152 int i=voices; 1153 int i=voices;
1153 while (i--) 1154 while (i--)
1154 if (voice[i].channel==c && 1155 if (voice[i].channel==c &&
1155 voice[i].status != VOICE_FREE && 1156 voice[i].status != VOICE_FREE &&
1156 voice[i].status != VOICE_DIE) 1157 voice[i].status != VOICE_DIE)
1157 { 1158 {
@@ -1232,29 +1233,29 @@ static void seek_forward(int32 until_time)
1232 current_event->a; 1233 current_event->a;
1233 channel[current_event->channel].pitchfactor=0; 1234 channel[current_event->channel].pitchfactor=0;
1234 break; 1235 break;
1235 1236
1236 case ME_PITCHWHEEL: 1237 case ME_PITCHWHEEL:
1237 channel[current_event->channel].pitchbend= 1238 channel[current_event->channel].pitchbend=
1238 current_event->a + current_event->b * 128; 1239 current_event->a + current_event->b * 128;
1239 channel[current_event->channel].pitchfactor=0; 1240 channel[current_event->channel].pitchfactor=0;
1240 break; 1241 break;
1241 1242
1242 case ME_MAINVOLUME: 1243 case ME_MAINVOLUME:
1243 channel[current_event->channel].volume=current_event->a; 1244 channel[current_event->channel].volume=current_event->a;
1244 break; 1245 break;
1245 1246
1246 case ME_MASTERVOLUME: 1247 case ME_MASTERVOLUME:
1247 adjust_master_volume(current_event->a + (current_event->b <<7)); 1248 adjust_master_volume(current_event->a + (current_event->b <<7));
1248 break; 1249 break;
1249 1250
1250 case ME_PAN: 1251 case ME_PAN:
1251 channel[current_event->channel].panning=current_event->a; 1252 channel[current_event->channel].panning=current_event->a;
1252 break; 1253 break;
1253 1254
1254 case ME_EXPRESSION: 1255 case ME_EXPRESSION:
1255 channel[current_event->channel].expression=current_event->a; 1256 channel[current_event->channel].expression=current_event->a;
1256 break; 1257 break;
1257 1258
1258 case ME_PROGRAM: 1259 case ME_PROGRAM:
1259 /* if (ISDRUMCHANNEL(current_event->channel)) */ 1260 /* if (ISDRUMCHANNEL(current_event->channel)) */
1260 if (channel[current_event->channel].kit) 1261 if (channel[current_event->channel].kit)
@@ -1310,11 +1311,11 @@ static void seek_forward(int32 until_time)
1310 case ME_RESET_CONTROLLERS: 1311 case ME_RESET_CONTROLLERS:
1311 reset_controllers(current_event->channel); 1312 reset_controllers(current_event->channel);
1312 break; 1313 break;
1313 1314
1314 case ME_TONE_BANK: 1315 case ME_TONE_BANK:
1315 channel[current_event->channel].bank=current_event->a; 1316 channel[current_event->channel].bank=current_event->a;
1316 break; 1317 break;
1317 1318
1318 case ME_EOT: 1319 case ME_EOT:
1319 current_sample=current_event->time; 1320 current_sample=current_event->time;
1320 return; 1321 return;
@@ -1336,7 +1337,7 @@ static void skip_to(int32 until_time)
1336 buffered_count=0; 1337 buffered_count=0;
1337 buffer_pointer=common_buffer; 1338 buffer_pointer=common_buffer;
1338 current_event=event_list; 1339 current_event=event_list;
1339 1340
1340 if (until_time) 1341 if (until_time)
1341 seek_forward(until_time); 1342 seek_forward(until_time);
1342 ctl->reset(); 1343 ctl->reset();
@@ -1351,15 +1352,15 @@ static int apply_controls(void)
1351 switch(rc=ctl->read(&val)) 1352 switch(rc=ctl->read(&val))
1352 { 1353 {
1353 case RC_QUIT: /* [] */ 1354 case RC_QUIT: /* [] */
1354 case RC_LOAD_FILE: 1355 case RC_LOAD_FILE:
1355 case RC_NEXT: /* >>| */ 1356 case RC_NEXT: /* >>| */
1356 case RC_REALLY_PREVIOUS: /* |<< */ 1357 case RC_REALLY_PREVIOUS: /* |<< */
1357 return rc; 1358 return rc;
1358 1359
1359 case RC_CHANGE_VOLUME: 1360 case RC_CHANGE_VOLUME:
1360 if (val>0 || amplification > -val) 1361 if (val>0 || amplification > -val)
1361 amplification += val; 1362 amplification += val;
1362 else 1363 else
1363 amplification=0; 1364 amplification=0;
1364 if (amplification > MAX_AMPLIFICATION) 1365 if (amplification > MAX_AMPLIFICATION)
1365 amplification=MAX_AMPLIFICATION; 1366 amplification=MAX_AMPLIFICATION;
@@ -1382,20 +1383,20 @@ static int apply_controls(void)
1382 skip_to(0); 1383 skip_to(0);
1383 did_skip=1; 1384 did_skip=1;
1384 break; 1385 break;
1385 1386
1386 case RC_JUMP: 1387 case RC_JUMP:
1387 if (val >= sample_count) 1388 if (val >= sample_count)
1388 return RC_NEXT; 1389 return RC_NEXT;
1389 skip_to(val); 1390 skip_to(val);
1390 return rc; 1391 return rc;
1391 1392
1392 case RC_FORWARD: /* >> */ 1393 case RC_FORWARD: /* >> */
1393 if (val+current_sample >= sample_count) 1394 if (val+current_sample >= sample_count)
1394 return RC_NEXT; 1395 return RC_NEXT;
1395 skip_to(val+current_sample); 1396 skip_to(val+current_sample);
1396 did_skip=1; 1397 did_skip=1;
1397 break; 1398 break;
1398 1399
1399 case RC_BACK: /* << */ 1400 case RC_BACK: /* << */
1400 if (current_sample > val) 1401 if (current_sample > val)
1401 skip_to(current_sample-val); 1402 skip_to(current_sample-val);
@@ -1405,10 +1406,10 @@ static int apply_controls(void)
1405 break; 1406 break;
1406 } 1407 }
1407 while (rc!= RC_NONE); 1408 while (rc!= RC_NONE);
1408 1409
1409 /* Advertise the skip so that we stop computing the audio buffer */ 1410 /* Advertise the skip so that we stop computing the audio buffer */
1410 if (did_skip) 1411 if (did_skip)
1411 return RC_JUMP; 1412 return RC_JUMP;
1412 else 1413 else
1413 return rc; 1414 return rc;
1414} 1415}
@@ -1466,7 +1467,7 @@ static int compute_data(void *stream, int32 count)
1466 s32tobuf(stream, common_buffer, channels*AUDIO_BUFFER_SIZE); 1467 s32tobuf(stream, common_buffer, channels*AUDIO_BUFFER_SIZE);
1467 buffer_pointer=common_buffer; 1468 buffer_pointer=common_buffer;
1468 buffered_count=0; 1469 buffered_count=0;
1469 1470
1470 ctl->current_time(current_sample); 1471 ctl->current_time(current_sample);
1471 if ((rc=apply_controls())!=RC_NONE) 1472 if ((rc=apply_controls())!=RC_NONE)
1472 return rc; 1473 return rc;
@@ -1485,7 +1486,7 @@ int Timidity_PlaySome(void *stream, int samples)
1485 //printf("Timidity_PlaySome()\n"); 1486 //printf("Timidity_PlaySome()\n");
1486 int rc = RC_NONE; 1487 int rc = RC_NONE;
1487 int32 end_sample; 1488 int32 end_sample;
1488 1489
1489 if ( ! midi_playing ) { 1490 if ( ! midi_playing ) {
1490 return RC_NONE; 1491 return RC_NONE;
1491 } 1492 }
@@ -1504,33 +1505,33 @@ int Timidity_PlaySome(void *stream, int samples)
1504 else 1505 else
1505 note_on(current_event); 1506 note_on(current_event);
1506 break; 1507 break;
1507 1508
1508 case ME_NOTEOFF: 1509 case ME_NOTEOFF:
1509 current_event->a += channel[current_event->channel].transpose; 1510 current_event->a += channel[current_event->channel].transpose;
1510 note_off(current_event); 1511 note_off(current_event);
1511 break; 1512 break;
1512 1513
1513 case ME_KEYPRESSURE: 1514 case ME_KEYPRESSURE:
1514 adjust_pressure(current_event); 1515 adjust_pressure(current_event);
1515 break; 1516 break;
1516 1517
1517 /* Effects affecting a single channel */ 1518 /* Effects affecting a single channel */
1518 1519
1519 case ME_PITCH_SENS: 1520 case ME_PITCH_SENS:
1520 channel[current_event->channel].pitchsens=current_event->a; 1521 channel[current_event->channel].pitchsens=current_event->a;
1521 channel[current_event->channel].pitchfactor=0; 1522 channel[current_event->channel].pitchfactor=0;
1522 break; 1523 break;
1523 1524
1524 case ME_PITCHWHEEL: 1525 case ME_PITCHWHEEL:
1525 channel[current_event->channel].pitchbend= 1526 channel[current_event->channel].pitchbend=
1526 current_event->a + current_event->b * 128; 1527 current_event->a + current_event->b * 128;
1527 channel[current_event->channel].pitchfactor=0; 1528 channel[current_event->channel].pitchfactor=0;
1528 /* Adjust pitch for notes already playing */ 1529 /* Adjust pitch for notes already playing */
1529 adjust_pitchbend(current_event->channel); 1530 adjust_pitchbend(current_event->channel);
1530 ctl->pitch_bend(current_event->channel, 1531 ctl->pitch_bend(current_event->channel,
1531 channel[current_event->channel].pitchbend); 1532 channel[current_event->channel].pitchbend);
1532 break; 1533 break;
1533 1534
1534 case ME_MAINVOLUME: 1535 case ME_MAINVOLUME:
1535 channel[current_event->channel].volume=current_event->a; 1536 channel[current_event->channel].volume=current_event->a;
1536 adjust_volume(current_event->channel); 1537 adjust_volume(current_event->channel);
@@ -1540,7 +1541,7 @@ int Timidity_PlaySome(void *stream, int samples)
1540 case ME_MASTERVOLUME: 1541 case ME_MASTERVOLUME:
1541 adjust_master_volume(current_event->a + (current_event->b <<7)); 1542 adjust_master_volume(current_event->a + (current_event->b <<7));
1542 break; 1543 break;
1543 1544
1544 case ME_REVERBERATION: 1545 case ME_REVERBERATION:
1545 channel[current_event->channel].reverberation=current_event->a; 1546 channel[current_event->channel].reverberation=current_event->a;
1546 break; 1547 break;
@@ -1555,13 +1556,13 @@ int Timidity_PlaySome(void *stream, int samples)
1555 adjust_panning(current_event->channel); 1556 adjust_panning(current_event->channel);
1556 ctl->panning(current_event->channel, current_event->a); 1557 ctl->panning(current_event->channel, current_event->a);
1557 break; 1558 break;
1558 1559
1559 case ME_EXPRESSION: 1560 case ME_EXPRESSION:
1560 channel[current_event->channel].expression=current_event->a; 1561 channel[current_event->channel].expression=current_event->a;
1561 adjust_volume(current_event->channel); 1562 adjust_volume(current_event->channel);
1562 ctl->expression(current_event->channel, current_event->a); 1563 ctl->expression(current_event->channel, current_event->a);
1563 break; 1564 break;
1564 1565
1565 case ME_PROGRAM: 1566 case ME_PROGRAM:
1566 /* if (ISDRUMCHANNEL(current_event->channel)) { */ 1567 /* if (ISDRUMCHANNEL(current_event->channel)) { */
1567 if (channel[current_event->channel].kit) { 1568 if (channel[current_event->channel].kit) {
@@ -1574,23 +1575,23 @@ int Timidity_PlaySome(void *stream, int samples)
1574 } 1575 }
1575 ctl->program(current_event->channel, current_event->a); 1576 ctl->program(current_event->channel, current_event->a);
1576 break; 1577 break;
1577 1578
1578 case ME_SUSTAIN: 1579 case ME_SUSTAIN:
1579 channel[current_event->channel].sustain=current_event->a; 1580 channel[current_event->channel].sustain=current_event->a;
1580 if (!current_event->a) 1581 if (!current_event->a)
1581 drop_sustain(current_event->channel); 1582 drop_sustain(current_event->channel);
1582 ctl->sustain(current_event->channel, current_event->a); 1583 ctl->sustain(current_event->channel, current_event->a);
1583 break; 1584 break;
1584 1585
1585 case ME_RESET_CONTROLLERS: 1586 case ME_RESET_CONTROLLERS:
1586 reset_controllers(current_event->channel); 1587 reset_controllers(current_event->channel);
1587 redraw_controllers(current_event->channel); 1588 redraw_controllers(current_event->channel);
1588 break; 1589 break;
1589 1590
1590 case ME_ALL_NOTES_OFF: 1591 case ME_ALL_NOTES_OFF:
1591 all_notes_off(current_event->channel); 1592 all_notes_off(current_event->channel);
1592 break; 1593 break;
1593 1594
1594 case ME_ALL_SOUNDS_OFF: 1595 case ME_ALL_SOUNDS_OFF:
1595 all_sounds_off(current_event->channel); 1596 all_sounds_off(current_event->channel);
1596 break; 1597 break;
@@ -1725,7 +1726,7 @@ void Timidity_FreeSong(MidiSong *song)
1725{ 1726{
1726 if (free_instruments_afterwards) 1727 if (free_instruments_afterwards)
1727 free_instruments(); 1728 free_instruments();
1728 1729
1729 free(song->events); 1730 free(song->events);
1730 free(song); 1731 free(song);
1731} 1732}
@@ -1743,4 +1744,3 @@ void Timidity_Close(void)
1743 free_instruments(); 1744 free_instruments();
1744 free_pathlist(); 1745 free_pathlist();
1745} 1746}
1746
diff --git a/apps/plugins/sdl/SDL_mixer/timidity/readmidi.c b/apps/plugins/sdl/SDL_mixer/timidity/readmidi.c
index afd3f9f571..d08a6f7dd4 100644
--- a/apps/plugins/sdl/SDL_mixer/timidity/readmidi.c
+++ b/apps/plugins/sdl/SDL_mixer/timidity/readmidi.c
@@ -6,9 +6,10 @@
6 it under the terms of the Perl Artistic License, available in COPYING. 6 it under the terms of the Perl Artistic License, available in COPYING.
7 */ 7 */
8 8
9#include "config.h"
10
9#include <SDL_rwops.h> 11#include <SDL_rwops.h>
10 12
11#include "config.h"
12#include "common.h" 13#include "common.h"
13#include "instrum.h" 14#include "instrum.h"
14#include "playmidi.h" 15#include "playmidi.h"
@@ -282,11 +283,11 @@ static MidiEventList *read_midi_event(void)
282 at+=getvl(); 283 at+=getvl();
283 if (SDL_RWread(rw,&me,1,1)!=1) 284 if (SDL_RWread(rw,&me,1,1)!=1)
284 { 285 {
285 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: read_midi_event: %s", 286 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: read_midi_event: %s",
286 current_filename, strerror(errno)); 287 current_filename, strerror(errno));
287 return 0; 288 return 0;
288 } 289 }
289 290
290 if(me==0xF0 || me == 0xF7) /* SysEx event */ 291 if(me==0xF0 || me == 0xF7) /* SysEx event */
291 { 292 {
292 int32 sret; 293 int32 sret;
@@ -340,9 +341,9 @@ static MidiEventList *read_midi_event(void)
340 case 0x51: /* Tempo */ 341 case 0x51: /* Tempo */
341 SDL_RWread(rw,&a,1,1); SDL_RWread(rw,&b,1,1); SDL_RWread(rw,&c,1,1); 342 SDL_RWread(rw,&a,1,1); SDL_RWread(rw,&b,1,1); SDL_RWread(rw,&c,1,1);
342 MIDIEVENT(at, ME_TEMPO, c, a, b); 343 MIDIEVENT(at, ME_TEMPO, c, a, b);
343 344
344 default: 345 default:
345 ctl->cmsg(CMSG_INFO, VERB_DEBUG, 346 ctl->cmsg(CMSG_INFO, VERB_DEBUG,
346 "(Meta event type 0x%02x, length %ld)", type, len); 347 "(Meta event type 0x%02x, length %ld)", type, len);
347 SDL_RWseek(rw, len, RW_SEEK_CUR); 348 SDL_RWseek(rw, len, RW_SEEK_CUR);
348 break; 349 break;
@@ -414,7 +415,7 @@ static MidiEventList *read_midi_event(void)
414 case 101: nrpn=0; rpn_lsb[lastchan]=b; break; 415 case 101: nrpn=0; rpn_lsb[lastchan]=b; break;
415 case 99: nrpn=1; rpn_msb[lastchan]=b; break; 416 case 99: nrpn=1; rpn_msb[lastchan]=b; break;
416 case 98: nrpn=1; rpn_lsb[lastchan]=b; break; 417 case 98: nrpn=1; rpn_lsb[lastchan]=b; break;
417 418
418 case 6: 419 case 6:
419 if (nrpn) 420 if (nrpn)
420 { 421 {
@@ -455,13 +456,13 @@ static MidiEventList *read_midi_event(void)
455 */ 456 */
456 } 457 }
457 458
458 ctl->cmsg(CMSG_INFO, VERB_DEBUG, 459 ctl->cmsg(CMSG_INFO, VERB_DEBUG,
459 "(Data entry (MSB) for NRPN %02x,%02x: %ld)", 460 "(Data entry (MSB) for NRPN %02x,%02x: %ld)",
460 rpn_msb[lastchan], rpn_lsb[lastchan], 461 rpn_msb[lastchan], rpn_lsb[lastchan],
461 b); 462 b);
462 break; 463 break;
463 } 464 }
464 465
465 switch((rpn_msb[lastchan]<<8) | rpn_lsb[lastchan]) 466 switch((rpn_msb[lastchan]<<8) | rpn_lsb[lastchan])
466 { 467 {
467 case 0x0000: /* Pitch bend sensitivity */ 468 case 0x0000: /* Pitch bend sensitivity */
@@ -473,22 +474,22 @@ static MidiEventList *read_midi_event(void)
473 MIDIEVENT(at, ME_PITCH_SENS, lastchan, 2, 0); 474 MIDIEVENT(at, ME_PITCH_SENS, lastchan, 2, 0);
474 475
475 default: 476 default:
476 ctl->cmsg(CMSG_INFO, VERB_DEBUG, 477 ctl->cmsg(CMSG_INFO, VERB_DEBUG,
477 "(Data entry (MSB) for RPN %02x,%02x: %ld)", 478 "(Data entry (MSB) for RPN %02x,%02x: %ld)",
478 rpn_msb[lastchan], rpn_lsb[lastchan], 479 rpn_msb[lastchan], rpn_lsb[lastchan],
479 b); 480 b);
480 break; 481 break;
481 } 482 }
482 break; 483 break;
483 484
484 default: 485 default:
485 ctl->cmsg(CMSG_INFO, VERB_DEBUG, 486 ctl->cmsg(CMSG_INFO, VERB_DEBUG,
486 "(Control %d: %d)", a, b); 487 "(Control %d: %d)", a, b);
487 break; 488 break;
488 } 489 }
489 if (control != 255) 490 if (control != 255)
490 { 491 {
491 MIDIEVENT(at, control, lastchan, b, 0); 492 MIDIEVENT(at, control, lastchan, b, 0);
492 } 493 }
493 } 494 }
494 break; 495 break;
@@ -505,15 +506,15 @@ static MidiEventList *read_midi_event(void)
505 b &= 0x7F; 506 b &= 0x7F;
506 MIDIEVENT(at, ME_PITCHWHEEL, lastchan, a, b); 507 MIDIEVENT(at, ME_PITCHWHEEL, lastchan, a, b);
507 508
508 default: 509 default:
509 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 510 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
510 "*** Can't happen: status 0x%02X, channel 0x%02X", 511 "*** Can't happen: status 0x%02X, channel 0x%02X",
511 laststatus, lastchan); 512 laststatus, lastchan);
512 break; 513 break;
513 } 514 }
514 } 515 }
515 } 516 }
516 517
517 return new; 518 return new;
518} 519}
519 520
@@ -574,7 +575,7 @@ static int read_track(int append)
574 meep=next; 575 meep=next;
575 next=meep->next; 576 next=meep->next;
576 } 577 }
577 578
578 new->next=next; 579 new->next=next;
579 meep->next=new; 580 meep->next=new;
580 581
@@ -720,7 +721,7 @@ static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp)
720 } 721 }
721 if (current_set[meep->event.channel] != new_value) 722 if (current_set[meep->event.channel] != new_value)
722 current_set[meep->event.channel]=new_value; 723 current_set[meep->event.channel]=new_value;
723 else 724 else
724 skip_this_event=1; 725 skip_this_event=1;
725 } 726 }
726 else 727 else
@@ -776,7 +777,7 @@ static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp)
776 if (mprog==SPECIAL_PROGRAM) 777 if (mprog==SPECIAL_PROGRAM)
777 break; 778 break;
778 779
779 if (XG_System_On && banknum==SFXBANK && !tonebank[SFXBANK] && tonebank[120]) 780 if (XG_System_On && banknum==SFXBANK && !tonebank[SFXBANK] && tonebank[120])
780 banknum = 120; 781 banknum = 120;
781 782
782 /*if (current_config_pc42b) pcmap(&banknum, &dnote, &mprog, &drumsflag);*/ 783 /*if (current_config_pc42b) pcmap(&banknum, &dnote, &mprog, &drumsflag);*/
@@ -812,7 +813,7 @@ static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp)
812 new_value=meep->event.a; 813 new_value=meep->event.a;
813 if (current_kit[meep->event.channel] != new_value) 814 if (current_kit[meep->event.channel] != new_value)
814 current_kit[meep->event.channel]=new_value; 815 current_kit[meep->event.channel]=new_value;
815 else 816 else
816 skip_this_event=1; 817 skip_this_event=1;
817 break; 818 break;
818 } 819 }
@@ -846,7 +847,7 @@ static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp)
846 } 847 }
847 if (tonebank[SFXBANK] || tonebank[120]) /* Is this a defined tone bank? */ 848 if (tonebank[SFXBANK] || tonebank[120]) /* Is this a defined tone bank? */
848 new_value=SFX_BANKTYPE; 849 new_value=SFX_BANKTYPE;
849 else 850 else
850 { 851 {
851 ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, 852 ctl->cmsg(CMSG_WARNING, VERB_VERBOSE,
852 "XG Sfx bank is undefined"); 853 "XG Sfx bank is undefined");
@@ -873,7 +874,7 @@ static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp)
873 } 874 }
874 else if (tonebank[meep->event.a]) /* Is this a defined tone bank? */ 875 else if (tonebank[meep->event.a]) /* Is this a defined tone bank? */
875 new_value=meep->event.a; 876 new_value=meep->event.a;
876 else 877 else
877 { 878 {
878 ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, 879 ctl->cmsg(CMSG_WARNING, VERB_VERBOSE,
879 "Tone bank %d is undefined", meep->event.a); 880 "Tone bank %d is undefined", meep->event.a);
@@ -924,7 +925,7 @@ static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp)
924 lp->type=ME_EOT; 925 lp->type=ME_EOT;
925 our_event_count++; 926 our_event_count++;
926 free_midi_list(); 927 free_midi_list();
927 928
928 *eventsp=our_event_count; 929 *eventsp=our_event_count;
929 *samplesp=st; 930 *samplesp=st;
930 return groomed_list; 931 return groomed_list;
@@ -968,11 +969,11 @@ past_riff:
968 { 969 {
969 /* if (ferror(fp)) 970 /* if (ferror(fp))
970 { 971 {
971 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", current_filename, 972 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", current_filename,
972 strerror(errno)); 973 strerror(errno));
973 } 974 }
974 else*/ 975 else*/
975 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 976 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
976 "%s: Not a MIDI file!", current_filename); 977 "%s: Not a MIDI file!", current_filename);
977 return 0; 978 return 0;
978 } 979 }
@@ -1010,18 +1011,18 @@ past_riff:
1010 1011
1011 if (len > 6) 1012 if (len > 6)
1012 { 1013 {
1013 ctl->cmsg(CMSG_WARNING, VERB_NORMAL, 1014 ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
1014 "%s: MIDI file header size %ld bytes", 1015 "%s: MIDI file header size %ld bytes",
1015 current_filename, len); 1016 current_filename, len);
1016 SDL_RWseek(rw, len-6, RW_SEEK_CUR); /* skip the excess */ 1017 SDL_RWseek(rw, len-6, RW_SEEK_CUR); /* skip the excess */
1017 } 1018 }
1018 if (format<0 || format >2) 1019 if (format<0 || format >2)
1019 { 1020 {
1020 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 1021 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
1021 "%s: Unknown MIDI file format %d", current_filename, format); 1022 "%s: Unknown MIDI file format %d", current_filename, format);
1022 return 0; 1023 return 0;
1023 } 1024 }
1024 ctl->cmsg(CMSG_INFO, VERB_VERBOSE, 1025 ctl->cmsg(CMSG_INFO, VERB_VERBOSE,
1025 "Format: %d Tracks: %d Divisions: %d", format, tracks, divisions); 1026 "Format: %d Tracks: %d Divisions: %d", format, tracks, divisions);
1026 1027
1027 /* Put a do-nothing event first in the list for easier processing */ 1028 /* Put a do-nothing event first in the list for easier processing */
diff --git a/apps/plugins/sdl/SDL_mixer/timidity/timidity.c b/apps/plugins/sdl/SDL_mixer/timidity/timidity.c
index 7d3214f5f6..fbb90e832f 100644
--- a/apps/plugins/sdl/SDL_mixer/timidity/timidity.c
+++ b/apps/plugins/sdl/SDL_mixer/timidity/timidity.c
@@ -6,8 +6,8 @@
6 it under the terms of the Perl Artistic License, available in COPYING. 6 it under the terms of the Perl Artistic License, available in COPYING.
7 */ 7 */
8 8
9#include "SDL.h"
10#include "config.h" 9#include "config.h"
10#include "SDL.h"
11#include "common.h" 11#include "common.h"
12#include "instrum.h" 12#include "instrum.h"
13#include "playmidi.h" 13#include "playmidi.h"
@@ -88,7 +88,7 @@ static int read_config_file(const char *name)
88 { 88 {
89 if (words != 2) 89 if (words != 2)
90 { 90 {
91 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 91 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
92 "%s: line %d: Must specify exactly one patch name\n", 92 "%s: line %d: Must specify exactly one patch name\n",
93 name, line); 93 name, line);
94 return -2; 94 return -2;
@@ -101,14 +101,14 @@ static int read_config_file(const char *name)
101 if (words < 2) 101 if (words < 2)
102 { 102 {
103 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 103 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
104 "%s: line %d: No drum set number given\n", 104 "%s: line %d: No drum set number given\n",
105 name, line); 105 name, line);
106 return -2; 106 return -2;
107 } 107 }
108 i=atoi(w[1]); 108 i=atoi(w[1]);
109 if (i<0 || i>127) 109 if (i<0 || i>127)
110 { 110 {
111 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 111 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
112 "%s: line %d: Drum set must be between 0 and 127\n", 112 "%s: line %d: Drum set must be between 0 and 127\n",
113 name, line); 113 name, line);
114 return -2; 114 return -2;
@@ -125,14 +125,14 @@ static int read_config_file(const char *name)
125 if (words < 2) 125 if (words < 2)
126 { 126 {
127 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 127 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
128 "%s: line %d: No bank number given\n", 128 "%s: line %d: No bank number given\n",
129 name, line); 129 name, line);
130 return -2; 130 return -2;
131 } 131 }
132 i=atoi(w[1]); 132 i=atoi(w[1]);
133 if (i<0 || i>127) 133 if (i<0 || i>127)
134 { 134 {
135 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 135 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
136 "%s: line %d: Tone bank must be between 0 and 127\n", 136 "%s: line %d: Tone bank must be between 0 and 127\n",
137 name, line); 137 name, line);
138 return -2; 138 return -2;
@@ -161,7 +161,7 @@ static int read_config_file(const char *name)
161 } 161 }
162 if (!bank) 162 if (!bank)
163 { 163 {
164 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 164 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
165 "%s: line %d: Must specify tone bank or drum set " 165 "%s: line %d: Must specify tone bank or drum set "
166 "before assignment\n", 166 "before assignment\n",
167 name, line); 167 name, line);
@@ -188,7 +188,7 @@ static int read_config_file(const char *name)
188 k=atoi(cp); 188 k=atoi(cp);
189 if ((k<0 || k>MAX_AMPLIFICATION) || (*cp < '0' || *cp > '9')) 189 if ((k<0 || k>MAX_AMPLIFICATION) || (*cp < '0' || *cp > '9'))
190 { 190 {
191 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 191 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
192 "%s: line %d: amplification must be between " 192 "%s: line %d: amplification must be between "
193 "0 and %d\n", name, line, MAX_AMPLIFICATION); 193 "0 and %d\n", name, line, MAX_AMPLIFICATION);
194 return -2; 194 return -2;
@@ -200,7 +200,7 @@ static int read_config_file(const char *name)
200 k=atoi(cp); 200 k=atoi(cp);
201 if ((k<0 || k>127) || (*cp < '0' || *cp > '9')) 201 if ((k<0 || k>127) || (*cp < '0' || *cp > '9'))
202 { 202 {
203 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 203 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
204 "%s: line %d: note must be between 0 and 127\n", 204 "%s: line %d: note must be between 0 and 127\n",
205 name, line); 205 name, line);
206 return -2; 206 return -2;
@@ -220,7 +220,7 @@ static int read_config_file(const char *name)
220 if ((k<0 || k>127) || 220 if ((k<0 || k>127) ||
221 (k==0 && *cp!='-' && (*cp < '0' || *cp > '9'))) 221 (k==0 && *cp!='-' && (*cp < '0' || *cp > '9')))
222 { 222 {
223 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 223 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
224 "%s: line %d: panning must be left, right, " 224 "%s: line %d: panning must be left, right, "
225 "center, or between -100 and 100\n", 225 "center, or between -100 and 100\n",
226 name, line); 226 name, line);
@@ -302,7 +302,7 @@ int Timidity_Init(int rate, int format, int channels, int samples)
302 } 302 }
303 if ( channels == 1 ) { 303 if ( channels == 1 ) {
304 play_mode->encoding |= PE_MONO; 304 play_mode->encoding |= PE_MONO;
305 } 305 }
306 switch (format) { 306 switch (format) {
307 case AUDIO_S8: 307 case AUDIO_S8:
308 s32tobuf = s32tos8; 308 s32tobuf = s32tos8;
@@ -356,4 +356,3 @@ const char *Timidity_Error(void)
356{ 356{
357 return(timidity_error); 357 return(timidity_error);
358} 358}
359