summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorStepan Moskovchenko <stevenm@rockbox.org>2005-04-16 03:35:20 +0000
committerStepan Moskovchenko <stevenm@rockbox.org>2005-04-16 03:35:20 +0000
commit4b773c0c4c1f6c8c003038161fa44292b501e55a (patch)
tree8bb3852df206f2edfdd68ccf79e50fc56798dd25 /apps
parentcdd35ba22062301a7c94ef0968a8b7ea842eca5f (diff)
downloadrockbox-4b773c0c4c1f6c8c003038161fa44292b501e55a.tar.gz
rockbox-4b773c0c4c1f6c8c003038161fa44292b501e55a.tar.bz2
rockbox-4b773c0c4c1f6c8c003038161fa44292b501e55a.zip
Added xxx2wav support, an icon, and some optimizations
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6306 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/midi/guspat.c12
-rw-r--r--apps/plugins/midi/synth.c22
-rw-r--r--apps/plugins/midi2wav.c37
-rw-r--r--apps/plugins/viewers.config2
4 files changed, 48 insertions, 25 deletions
diff --git a/apps/plugins/midi/guspat.c b/apps/plugins/midi/guspat.c
index 6508591f74..f674b64caa 100644
--- a/apps/plugins/midi/guspat.c
+++ b/apps/plugins/midi/guspat.c
@@ -66,6 +66,18 @@ struct GWaveform * loadWaveform(int file)
wav->res=readData(file, 36);
wav->data=readData(file, wav->wavSize);
+ int a=0;
+
+ //If we have a 16 bit waveform
+ if(wav->mode & 1 && (wav->mode & 2))
+ {
+ for(a=0; a<wav->wavSize; a+=2) //Convert it to
+ {
+ //wav->data[a]=wav->data[a]; //+((wav->mode & 2) << 6);
+ wav->data[a|1]=wav->data[(a)|1]+(1 << 7);
+ }
+ }
+
return wav;
}
diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c
index 86cb43483a..99864e557e 100644
--- a/apps/plugins/midi/synth.c
+++ b/apps/plugins/midi/synth.c
@@ -186,10 +186,7 @@ inline signed short int getSample(struct GWaveform * wf, unsigned int s)
{
if(s<<1 >= wf->wavSize)
- {
- // printf("\nSAMPLE OUT OF RANGE: s=%d 2s=%d ws=%d", s, 2*s, wf->wavSize);
return 0;
- }
/*
@@ -198,14 +195,14 @@ inline signed short int getSample(struct GWaveform * wf, unsigned int s)
*/
- //If they are unsigned, convert them to signed
- //or was it the other way around. Whatever, it works
- unsigned char b1=wf->data[s<<1]+((wf->mode & 2) << 6);
- unsigned char b2=wf->data[(s<<1)|1]+((wf->mode & 2) << 6);
- return (b1 | (b2<<8));
+ //Sign conversion moved into guspat.c
+ unsigned char b1=wf->data[s<<1]; //+((wf->mode & 2) << 6);
+ unsigned char b2=wf->data[(s<<1)|1]; //+((wf->mode & 2) << 6);
+ return (b1 | (b2<<8)) ;
}
else
- { //8-bit samples
+ { //8-bit samples
+ //Do we even have anything 8-bit in our set?
unsigned char b1=wf->data[s]+((wf->mode & 2) << 6);
return b1<<8;
}
@@ -237,10 +234,6 @@ inline void setPoint(struct SynthObject * so, int pt)
so->curPoint = pt;
int r=0;
-
-
-
-
int rate = so->wf->envRate[pt];
r=3-((rate>>6) & 0x3); // Some blatant Timidity code for rate conversion...
@@ -256,7 +249,7 @@ inline void setPoint(struct SynthObject * so, int pt)
default this to 10, and maybe later have an option to set it to 9
for longer decays.
*/
- so->curRate = r<<9;
+ so->curRate = r<<10;
so->targetOffset = so->wf->envOffset[pt]<<(20);
@@ -372,6 +365,7 @@ inline signed short int synthVoice(int v)
if(so->curOffset < 0)
so->isUsed=0; //This is OK
+
s = s * (so->curOffset >> 22);
s = s>>6;
diff --git a/apps/plugins/midi2wav.c b/apps/plugins/midi2wav.c
index 0b1659b1dd..3cf2866a12 100644
--- a/apps/plugins/midi2wav.c
+++ b/apps/plugins/midi2wav.c
@@ -19,15 +19,21 @@
#define SAMPLE_RATE 48000
#define MAX_VOICES 100
-/*
+
+//Only define LOCAL_DSP on Simulator or else we're asking for trouble
#if defined(SIMULATOR)
+ //Enable this to write to the soundcard via a /dsv/dsp symlink in /
+// #define LOCAL_DSP
+#endif
+
+
+#if defined(LOCAL_DSP)
// This is for writing to the DSP directly from the Simulator
#include <stdio.h>
#include <stdlib.h>
#include <linux/soundcard.h>
#include <sys/ioctl.h>
#endif
-*/
#include "../../plugin.h"
@@ -40,9 +46,9 @@
-//#include "lib/xxx2wav.h"
+#include "lib/xxx2wav.h"
-int fd=-1; //File descriptor, for opening /dev/dsp and writing to it
+int fd=-1; //File descriptor where the output is written
extern long tempo; //The sequencer keeps track of this
@@ -93,14 +99,12 @@ int midimain(void * filename)
return -1;
}
- fd=rb->open("/dsp.raw", O_WRONLY|O_CREAT);
-
-/*
//This lets you hear the music through the sound card if you are on Simulator
//Make a symlink, archos/dsp.raw and make it point to /dev/dsp or whatever
//your sound device is.
-#if defined(SIMULATOR)
+#if defined(LOCAL_DSP)
+ fd=rb->open("/dsp.raw", O_WRONLY);
int arg, status;
int bit, samp, ch;
@@ -119,8 +123,15 @@ int midimain(void * filename)
status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg);
status = ioctl(fd, SOUND_PCM_READ_RATE, &arg);
samp=arg;
+#else
+ file_info_struct file_info;
+ file_info.samplerate = 48000;
+ file_info.infile = fd;
+ file_info.channels = 2;
+ file_info.bitspersample = 16;
+ local_init("/miditest.tmp", "/miditest.wav", &file_info, rb);
+ fd = file_info.outfile;
#endif
-*/
rb->splash(HZ/5, true, " START PLAYING ");
@@ -190,6 +201,12 @@ int midimain(void * filename)
// unloadFile(mf);
printf("\n");
- rb->close(fd);
+
+#if !defined(LOCAL_DSP)
+
+ close_wav(&file_info);
+#else
+ rb->close(fd);
+#endif
return 0;
}
diff --git a/apps/plugins/viewers.config b/apps/plugins/viewers.config
index 9b30e20f7b..0b4f847322 100644
--- a/apps/plugins/viewers.config
+++ b/apps/plugins/viewers.config
@@ -17,4 +17,4 @@ ogg,vorbis2wav.rock, 00 00 00 00 00 00
wv,wv2wav.rock, 00 00 00 00 00 00
m3u,iriverify.rock,00 00 00 00 00 00
mpc,mpc2wav.rock, 00 00 00 00 00 00
-mid,midi2wav.rock, 01 20 30 40 50 60
+mid,midi2wav.rock, 20 70 70 3F 00 00