summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2008-11-10 15:54:43 +0000
committerBjörn Stenberg <bjorn@haxx.se>2008-11-10 15:54:43 +0000
commitdd226ea7355f7fe4c4c0f8b52a2f776470ed9829 (patch)
treebf780254bfd27f22b453b9c0f3885eec7b843190
parent889b8c96da5ed39d249f7b59c77316f63b7178f7 (diff)
downloadrockbox-dd226ea7355f7fe4c4c0f8b52a2f776470ed9829.tar.gz
rockbox-dd226ea7355f7fe4c4c0f8b52a2f776470ed9829.zip
Removing deprecated code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19068 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/midi2wav.c235
1 files changed, 0 insertions, 235 deletions
diff --git a/apps/plugins/midi2wav.c b/apps/plugins/midi2wav.c
deleted file mode 100644
index cee9d28b20..0000000000
--- a/apps/plugins/midi2wav.c
+++ /dev/null
@@ -1,235 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2005 Stepan Moskovchenko
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#define SAMPLE_RATE 22050
22#define MAX_VOICES 100
23
24
25/* Only define LOCAL_DSP on Simulator or else we're asking for trouble */
26#if defined(SIMULATOR)
27 /*Enable this to write to the soundcard via a /dsv/dsp symlink in */
28 /*#define LOCAL_DSP */
29#endif
30
31
32#if defined(LOCAL_DSP)
33/* This is for writing to the DSP directly from the Simulator */
34#include <stdio.h>
35#include <stdlib.h>
36#include <linux/soundcard.h>
37#include <sys/ioctl.h>
38#endif
39
40#include "../../firmware/export/system.h"
41
42#include "../../plugin.h"
43
44/*#include "../codecs/lib/xxx2wav.h" */
45
46PLUGIN_HEADER
47
48int numberOfSamples IDATA_ATTR;
49long bpm;
50
51#include "midi/midiutil.c"
52#include "midi/guspat.h"
53#include "midi/guspat.c"
54#include "midi/sequencer.c"
55#include "midi/midifile.c"
56#include "midi/synth.c"
57
58
59int fd=-1; /* File descriptor where the output is written */
60
61extern long tempo; /* The sequencer keeps track of this */
62
63const struct plugin_api * rb;
64
65
66enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
67{
68 (void)parameter;
69 rb = api;
70
71 if(parameter == NULL)
72 {
73 rb->splash(HZ*2, "Play .MID file");
74 return PLUGIN_OK;
75 }
76
77 rb->splash(HZ, parameter);
78 if(midimain(parameter) == -1)
79 {
80 return PLUGIN_ERROR;
81 }
82 rb->splash(HZ*3, "FINISHED PLAYING");
83 /* Return PLUGIN_USB_CONNECTED to force a file-tree refresh */
84 return PLUGIN_USB_CONNECTED;
85}
86
87signed char outputBuffer[3000] IDATA_ATTR; /* signed char.. gonna run out of iram ... ! */
88
89
90int currentSample IDATA_ATTR;
91int outputBufferPosition IDATA_ATTR;
92int outputSampleOne IDATA_ATTR;
93int outputSampleTwo IDATA_ATTR;
94
95
96int midimain(void * filename)
97{
98
99 printf("\nHello.\n");
100
101 rb->splash(HZ/5, "LOADING MIDI");
102
103 struct MIDIfile * mf = loadFile(filename);
104
105 rb->splash(HZ/5, "LOADING PATCHES");
106 if (initSynth(mf, ROCKBOX_DIR "/patchset/patchset.cfg",
107 ROCKBOX_DIR "/patchset/drums.cfg") == -1)
108 {
109 return -1;
110 }
111
112/*
113 * This lets you hear the music through the sound card if you are on Simulator
114 * Make a symlink, archos/dsp.raw and make it point to /dev/dsp or whatever
115 * your sound device is.
116 */
117
118#if defined(LOCAL_DSP)
119 fd=rb->open("/dsp.raw", O_WRONLY);
120 int arg, status;
121 int bit, samp, ch;
122
123 arg = 16; /* sample size */
124 status = ioctl(fd, SOUND_PCM_WRITE_BITS, &arg);
125 status = ioctl(fd, SOUND_PCM_READ_BITS, &arg);
126 bit=arg;
127
128
129 arg = 2; /* Number of channels, 1=mono */
130 status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &arg);
131 status = ioctl(fd, SOUND_PCM_READ_CHANNELS, &arg);
132 ch=arg;
133
134 arg = SAMPLE_RATE; /* Yeah. sampling rate */
135 status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg);
136 status = ioctl(fd, SOUND_PCM_READ_RATE, &arg);
137 samp=arg;
138#else
139
140/* xxx2wav stuff, removed for now, will move to the real way of outputting sound soon */
141/*
142 file_info_struct file_info;
143 file_info.samplerate = SAMPLE_RATE;
144 file_info.infile = fd;
145 file_info.channels = 2;
146 file_info.bitspersample = 16;
147 local_init("/miditest.tmp", "/miditest.wav", &file_info, rb);
148 fd = file_info.outfile;
149*/
150#endif
151
152
153 rb->splash(HZ/5, "I hope this works...");
154
155
156
157
158 /*
159 * tick() will do one MIDI clock tick. Then, there's a loop here that
160 * will generate the right number of samples per MIDI tick. The whole
161 * MIDI playback is timed in terms of this value.. there are no forced
162 * delays or anything. It just produces enough samples for each tick, and
163 * the playback of these samples is what makes the timings right.
164 *
165 * This seems to work quite well.
166 */
167
168 printf("\nOkay, starting sequencing");
169
170
171 currentSample=0; /* Sample counting variable */
172 outputBufferPosition = 0;
173
174
175 bpm=mf->div*1000000/tempo;
176 numberOfSamples=SAMPLE_RATE/bpm;
177
178
179
180 /* Tick() will return 0 if there are no more events left to play */
181 while(tick(mf))
182 {
183 /*
184 * Tempo recalculation moved to sequencer.c to be done on a tempo event only
185 *
186 */
187 for(currentSample=0; currentSample<numberOfSamples; currentSample++)
188 {
189
190 synthSample(&outputSampleOne, &outputSampleTwo);
191
192
193 /*
194 * 16-bit audio because, well, it's better
195 * But really because ALSA's OSS emulation sounds extremely
196 * noisy and distorted when in 8-bit mode. I still do not know
197 * why this happens.
198 */
199
200 outputBuffer[outputBufferPosition]=outputSampleOne&0XFF; /* Low byte first */
201 outputBufferPosition++;
202 outputBuffer[outputBufferPosition]=outputSampleOne>>8; /*High byte second */
203 outputBufferPosition++;
204
205 outputBuffer[outputBufferPosition]=outputSampleTwo&0XFF; /* Low byte first */
206 outputBufferPosition++;
207 outputBuffer[outputBufferPosition]=outputSampleTwo>>8; /*High byte second */
208 outputBufferPosition++;
209
210
211 /*
212 * As soon as we produce 2000 bytes of sound,
213 * write it to the sound card. Why 2000? I have
214 * no idea. It's 1 AM and I am dead tired.
215 */
216 if(outputBufferPosition>=2000)
217 {
218 rb->write(fd, outputBuffer, 2000);
219 outputBufferPosition=0;
220 }
221 }
222 }
223
224 printf("\n");
225
226#if !defined(LOCAL_DSP)
227
228/* again, xxx2wav stuff, removed for now */
229
230 /* close_wav(&file_info); */
231#else
232 rb->close(fd);
233#endif
234 return 0;
235}