diff options
Diffstat (limited to 'apps/plugins/midi2wav.c')
-rw-r--r-- | apps/plugins/midi2wav.c | 71 |
1 files changed, 49 insertions, 22 deletions
diff --git a/apps/plugins/midi2wav.c b/apps/plugins/midi2wav.c index f8368535d1..0b1659b1dd 100644 --- a/apps/plugins/midi2wav.c +++ b/apps/plugins/midi2wav.c | |||
@@ -19,13 +19,17 @@ | |||
19 | #define SAMPLE_RATE 48000 | 19 | #define SAMPLE_RATE 48000 |
20 | #define MAX_VOICES 100 | 20 | #define MAX_VOICES 100 |
21 | 21 | ||
22 | /* This is for writing to the DSP directly from the Simulator | 22 | /* |
23 | #if defined(SIMULATOR) | ||
24 | // This is for writing to the DSP directly from the Simulator | ||
23 | #include <stdio.h> | 25 | #include <stdio.h> |
24 | #include <stdlib.h> | 26 | #include <stdlib.h> |
25 | #include <linux/soundcard.h> | 27 | #include <linux/soundcard.h> |
26 | #include <sys/ioctl.h> | 28 | #include <sys/ioctl.h> |
29 | #endif | ||
27 | */ | 30 | */ |
28 | 31 | ||
32 | |||
29 | #include "../../plugin.h" | 33 | #include "../../plugin.h" |
30 | #include "midi/midiutil.c" | 34 | #include "midi/midiutil.c" |
31 | #include "midi/guspat.h" | 35 | #include "midi/guspat.h" |
@@ -47,23 +51,56 @@ struct plugin_api * rb; | |||
47 | 51 | ||
48 | 52 | ||
49 | 53 | ||
54 | |||
50 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | 55 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) |
51 | { | 56 | { |
52 | TEST_PLUGIN_API(api); | 57 | TEST_PLUGIN_API(api); |
53 | (void)parameter; | 58 | rb = api; |
54 | rb = api; | 59 | TEST_PLUGIN_API(api); |
55 | rb->splash(HZ*2, true, "MIDI"); | 60 | (void)parameter; |
56 | midimain(); | 61 | rb = api; |
57 | rb->splash(HZ*2, true, "FINISHED PLAYING"); | 62 | |
58 | return PLUGIN_OK; | 63 | if(parameter == NULL) |
64 | { | ||
65 | rb->splash(HZ*2, true, " Play .MID file "); | ||
66 | return PLUGIN_OK; | ||
67 | } | ||
68 | rb->splash(HZ, true, parameter); | ||
69 | if(midimain(parameter) == -1) | ||
70 | { | ||
71 | return PLUGIN_ERROR; | ||
72 | } | ||
73 | rb->splash(HZ*3, true, "FINISHED PLAYING"); | ||
74 | return PLUGIN_OK; | ||
59 | } | 75 | } |
60 | 76 | ||
61 | 77 | ||
62 | int midimain() | 78 | int midimain(void * filename) |
63 | { | 79 | { |
64 | rb->splash(HZ*2, true, "OPENED DSP"); | 80 | |
81 | printf("\nHello.\n"); | ||
82 | |||
83 | rb->splash(HZ/5, true, "LOADING MIDI"); | ||
84 | |||
85 | struct MIDIfile * mf = loadFile(filename); | ||
86 | long bpm, nsmp, l; | ||
87 | |||
88 | int bp=0; | ||
89 | |||
90 | rb->splash(HZ/5, true, "LOADING PATCHES"); | ||
91 | if (initSynth(mf, "/.rockbox/patchset/patchset.cfg", "/.rockbox/patchset/drums.cfg") == -1) | ||
92 | { | ||
93 | return -1; | ||
94 | } | ||
95 | |||
65 | fd=rb->open("/dsp.raw", O_WRONLY|O_CREAT); | 96 | fd=rb->open("/dsp.raw", O_WRONLY|O_CREAT); |
97 | |||
66 | /* | 98 | /* |
99 | //This lets you hear the music through the sound card if you are on Simulator | ||
100 | //Make a symlink, archos/dsp.raw and make it point to /dev/dsp or whatever | ||
101 | //your sound device is. | ||
102 | |||
103 | #if defined(SIMULATOR) | ||
67 | int arg, status; | 104 | int arg, status; |
68 | int bit, samp, ch; | 105 | int bit, samp, ch; |
69 | 106 | ||
@@ -82,24 +119,14 @@ int midimain() | |||
82 | status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg); | 119 | status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg); |
83 | status = ioctl(fd, SOUND_PCM_READ_RATE, &arg); | 120 | status = ioctl(fd, SOUND_PCM_READ_RATE, &arg); |
84 | samp=arg; | 121 | samp=arg; |
122 | #endif | ||
85 | */ | 123 | */ |
86 | 124 | ||
87 | printf("\nHello.\n"); | ||
88 | // initSound(); //Open the computer's sound card | ||
89 | int a=0; | ||
90 | 125 | ||
91 | rb->splash(HZ*2, true, "LOADING MIDI"); | 126 | rb->splash(HZ/5, true, " START PLAYING "); |
92 | 127 | ||
93 | struct MIDIfile * mf = loadFile("/test.mid"); | ||
94 | 128 | ||
95 | rb->splash(HZ*2, true, "LOADED MIDI"); | ||
96 | long bpm, nsmp, l; | ||
97 | |||
98 | int bp=0; | ||
99 | 129 | ||
100 | rb->splash(HZ*2, true, "LOADING PATCHES"); | ||
101 | initSynth(mf, "/iriver2.cfg", "/drums.cfg"); //Initialize the MIDI syntehsizer | ||
102 | rb->splash(HZ*2, true, "START PLAYING"); | ||
103 | 130 | ||
104 | signed char buf[3000]; | 131 | signed char buf[3000]; |
105 | 132 | ||