forked from len0rd/rockbox
Some quick and dirty MIDI player optimizations, now it works on the X5 and M5 too
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13108 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
08e633c25c
commit
7c4b786851
3 changed files with 11 additions and 14 deletions
|
@ -29,9 +29,12 @@ unsigned int readDWord(int file)
|
||||||
return (readChar(file)<<0) | (readChar(file)<<8) | (readChar(file)<<16) | (readChar(file)<<24);
|
return (readChar(file)<<0) | (readChar(file)<<8) | (readChar(file)<<16) | (readChar(file)<<24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int curr_waveform;
|
||||||
|
struct GWaveform waveforms[32] IBSS_ATTR;
|
||||||
|
|
||||||
struct GWaveform * loadWaveform(int file)
|
struct GWaveform * loadWaveform(int file)
|
||||||
{
|
{
|
||||||
struct GWaveform * wav = (struct GWaveform *)malloc(sizeof(struct GWaveform));
|
struct GWaveform * wav = &waveforms[curr_waveform++];
|
||||||
rb->memset(wav, 0, sizeof(struct GWaveform));
|
rb->memset(wav, 0, sizeof(struct GWaveform));
|
||||||
|
|
||||||
wav->name=readData(file, 7);
|
wav->name=readData(file, 7);
|
||||||
|
|
|
@ -182,12 +182,7 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline short getSample(int s,struct GWaveform * wf )
|
#define getSample(s,wf) ((short *)(wf)->data)[s]
|
||||||
{
|
|
||||||
/* Sign conversion moved to guspat.c */
|
|
||||||
/* 8bit conversion NOT YET IMPLEMENTED in guspat.c */
|
|
||||||
return ((short *) wf->data)[s];
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPoint(struct SynthObject * so, int pt)
|
void setPoint(struct SynthObject * so, int pt)
|
||||||
{
|
{
|
||||||
|
@ -254,6 +249,7 @@ inline void stopVoice(struct SynthObject * so)
|
||||||
so->decay = 0;
|
so->decay = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signed short int synthVoice(struct SynthObject * so) ICODE_ATTR;
|
||||||
signed short int synthVoice(struct SynthObject * so)
|
signed short int synthVoice(struct SynthObject * so)
|
||||||
{
|
{
|
||||||
struct GWaveform * wf;
|
struct GWaveform * wf;
|
||||||
|
|
|
@ -81,7 +81,7 @@ PLUGIN_IRAM_DECLARE
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
#define SAMPLE_RATE 22050 // 44100 22050 11025
|
#define SAMPLE_RATE 22050 // 44100 22050 11025
|
||||||
#define MAX_VOICES 14 // Note: 24 midi channels is the minimum general midi
|
#define MAX_VOICES 20 // Note: 24 midi channels is the minimum general midi
|
||||||
// spec implementation
|
// spec implementation
|
||||||
#else // Simulator requires 44100, and we can afford to use more voices
|
#else // Simulator requires 44100, and we can afford to use more voices
|
||||||
#define SAMPLE_RATE 44100
|
#define SAMPLE_RATE 44100
|
||||||
|
@ -89,7 +89,7 @@ PLUGIN_IRAM_DECLARE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define BUF_SIZE 512
|
#define BUF_SIZE 256
|
||||||
#define NBUF 2
|
#define NBUF 2
|
||||||
|
|
||||||
#undef SYNC
|
#undef SYNC
|
||||||
|
@ -110,7 +110,7 @@ long bpm IBSS_ATTR;
|
||||||
#include "midi/midifile.c"
|
#include "midi/midifile.c"
|
||||||
#include "midi/synth.c"
|
#include "midi/synth.c"
|
||||||
|
|
||||||
short gmbuf[BUF_SIZE*NBUF] IBSS_ATTR;
|
long gmbuf[BUF_SIZE*NBUF];
|
||||||
|
|
||||||
int quit=0;
|
int quit=0;
|
||||||
struct plugin_api * rb;
|
struct plugin_api * rb;
|
||||||
|
@ -165,7 +165,7 @@ bool lastswap=1;
|
||||||
|
|
||||||
inline void synthbuf(void)
|
inline void synthbuf(void)
|
||||||
{
|
{
|
||||||
short *outptr;
|
long *outptr;
|
||||||
register int i;
|
register int i;
|
||||||
static int currentSample=0;
|
static int currentSample=0;
|
||||||
int synthtemp[2];
|
int synthtemp[2];
|
||||||
|
@ -183,9 +183,7 @@ inline void synthbuf(void)
|
||||||
{
|
{
|
||||||
synthSample(&synthtemp[0], &synthtemp[1]);
|
synthSample(&synthtemp[0], &synthtemp[1]);
|
||||||
currentSample++;
|
currentSample++;
|
||||||
*outptr=synthtemp[0]&0xFFFF;
|
*outptr=((synthtemp[0]&0xFFFF) << 16) | (synthtemp[1]&0xFFFF);
|
||||||
outptr++;
|
|
||||||
*outptr=synthtemp[1]&0xFFFF;
|
|
||||||
outptr++;
|
outptr++;
|
||||||
if(currentSample==numberOfSamples)
|
if(currentSample==numberOfSamples)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue