diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 8479cd8b9b..0c615ef363 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -122,7 +122,6 @@ nim.c #if CONFIG_CODEC == SWCODEC /* software codec platforms */ mp3_encoder.c -midiplay.c wav2wv.c #else /* hardware codec platforms */ #ifndef HAVE_MMC /* not for Ondio, has no remote control pin */ diff --git a/apps/plugins/SUBDIRS b/apps/plugins/SUBDIRS index f537fb8965..5047d617ff 100644 --- a/apps/plugins/SUBDIRS +++ b/apps/plugins/SUBDIRS @@ -42,6 +42,7 @@ doom /* For all the swcodec targets */ #if CONFIG_CODEC == SWCODEC +midi mpegplayer #endif diff --git a/apps/plugins/midi/Makefile b/apps/plugins/midi/Makefile new file mode 100644 index 0000000000..0d81c87b4b --- /dev/null +++ b/apps/plugins/midi/Makefile @@ -0,0 +1,74 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id $ +# + +INCLUDES = -I$(APPSDIR) -I.. -I. $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export \ + -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR) +CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET) $(EXTRA_DEFINES) \ + -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN + +ifdef APPEXTRA + INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA))) +endif + +LINKFILE := $(OBJDIR)/link.lds +DEPFILE = $(OBJDIR)/dep-midiplay + +# This sets up 'SRC' based on the files mentioned in SOURCES +include $(TOOLSDIR)/makesrc.inc + +SOURCES = $(SRC) +OBJS := $(SRC:%.c=$(OBJDIR)/%.o) +DIRS = . + +ifndef SIMVER + LDS := ../plugin.lds + OUTPUT = $(OUTDIR)/midiplay.rock +else ## simulators + OUTPUT = $(OUTDIR)/midiplay.rock +endif + +all: $(OUTPUT) + +ifndef SIMVER +$(OBJDIR)/midiplay.elf: $(OBJS) $(LINKFILE) $(BITMAPLIBS) + $(call PRINTS,LD $(@F))$(CC) $(CFLAGS) -o $@ $(OBJS) -L$(BUILDDIR) -lplugin -lgcc \ + $(LINKBITMAPS) -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/midiplay.map + +$(OUTPUT): $(OBJDIR)/midiplay.elf + $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@ +else + +################################################### +# This is the SDL simulator version + +$(OUTPUT): $(OBJS) + $(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $(OBJS) -L$(BUILDDIR) -lplugin $(LINKBITMAPS) -o $@ +ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN) +# 'x' must be kept or you'll have "Win32 error 5" +# $ fgrep 5 /usr/include/w32api/winerror.h | head -1 +# #define ERROR_ACCESS_DENIED 5L +else + @chmod -x $@ +endif + +endif # end of simulator section + +include $(TOOLSDIR)/make.inc + +# MEMORYSIZE should be passed on to this makefile with the chosen memory size +# given in number of MB +$(LINKFILE): $(LDS) + $(call PRINTS,build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) \ + $(DEFINES) -E -P - >$@ + +clean: + $(call PRINTS,cleaning midiplay)rm -rf $(OBJDIR)/midiplay + $(SILENT)rm -f $(OBJDIR)/midiplay.* $(DEPFILE) + +-include $(DEPFILE) diff --git a/apps/plugins/midi/SOURCES b/apps/plugins/midi/SOURCES new file mode 100644 index 0000000000..74c0bf1396 --- /dev/null +++ b/apps/plugins/midi/SOURCES @@ -0,0 +1,6 @@ +midifile.c +midiutil.c +sequencer.c +guspat.c +synth.c +midiplay.c diff --git a/apps/plugins/midi/guspat.c b/apps/plugins/midi/guspat.c index 2168766eab..f44e542e2d 100644 --- a/apps/plugins/midi/guspat.c +++ b/apps/plugins/midi/guspat.c @@ -5,6 +5,7 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ + * $Id$ * * Copyright (C) 2005 Stepan Moskovchenko * @@ -15,7 +16,9 @@ * KIND, either express or implied. * ****************************************************************************/ - +#include "plugin.h" +#include "guspat.h" +#include "midiutil.h" extern struct plugin_api * rb; @@ -119,8 +122,6 @@ struct GWaveform * loadWaveform(int file) return wav; } - - int selectWaveform(struct GPatch * pat, int midiNote) { /* We divide by 100 here because everyone's freq formula is slightly different */ @@ -137,7 +138,6 @@ int selectWaveform(struct GPatch * pat, int midiNote) return 0; } - struct GPatch * gusload(char * filename) { struct GPatch * gp = (struct GPatch *)malloc(sizeof(struct GPatch)); @@ -196,3 +196,4 @@ struct GPatch * gusload(char * filename) return gp; } + diff --git a/apps/plugins/midi/guspat.h b/apps/plugins/midi/guspat.h index e35f54b57a..3f858cd909 100644 --- a/apps/plugins/midi/guspat.h +++ b/apps/plugins/midi/guspat.h @@ -5,6 +5,7 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ + * $Id$ * * Copyright (C) 2005 Stepan Moskovchenko * diff --git a/apps/plugins/midi/midifile.c b/apps/plugins/midi/midifile.c index 7161818421..1fa648ff50 100644 --- a/apps/plugins/midi/midifile.c +++ b/apps/plugins/midi/midifile.c @@ -5,6 +5,7 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ + * $Id$ * * Copyright (C) 2005 Stepan Moskovchenko * @@ -15,8 +16,8 @@ * KIND, either express or implied. * ****************************************************************************/ - - +#include "plugin.h" +#include "midiutil.h" extern struct plugin_api * rb; @@ -234,7 +235,6 @@ struct Track * readTrack(int file) return trk; } - int readID(int file) { char id[5]; @@ -318,4 +318,3 @@ void unloadFile(struct MIDIfile * mf) } */ - diff --git a/apps/plugins/midi/midifile.h b/apps/plugins/midi/midifile.h new file mode 100644 index 0000000000..a1024d500b --- /dev/null +++ b/apps/plugins/midi/midifile.h @@ -0,0 +1,21 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Stepan Moskovchenko + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +struct MIDIfile * loadFile(char * filename); + diff --git a/apps/plugins/midiplay.c b/apps/plugins/midi/midiplay.c similarity index 92% rename from apps/plugins/midiplay.c rename to apps/plugins/midi/midiplay.c index f8a6929661..7a1176b1c9 100644 --- a/apps/plugins/midiplay.c +++ b/apps/plugins/midi/midiplay.c @@ -5,6 +5,7 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ + * $Id$ * * Copyright (C) 2005 Karl Kurbjun based on midi2wav by Stepan Moskovchenko * @@ -15,8 +16,12 @@ * KIND, either express or implied. * ****************************************************************************/ - -#include "../../plugin.h" +#include "plugin.h" +#include "guspat.h" +#include "midiutil.h" +#include "synth.h" +#include "sequencer.h" +#include "midifile.h" PLUGIN_HEADER PLUGIN_IRAM_DECLARE @@ -62,7 +67,6 @@ PLUGIN_IRAM_DECLARE #define BTN_UP BUTTON_UP #define BTN_DOWN BUTTON_DOWN - #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD #define BTN_QUIT BUTTON_POWER #define BTN_RIGHT BUTTON_RIGHT @@ -77,32 +81,6 @@ PLUGIN_IRAM_DECLARE #endif - - -#define FRACTSIZE 10 - -#ifndef SIMULATOR - -#if (HW_SAMPR_CAPS & SAMPR_CAP_22) -#define SAMPLE_RATE SAMPR_22 // 44100 22050 11025 -#else -#define SAMPLE_RATE SAMPR_44 // 44100 22050 11025 -#endif - -#define MAX_VOICES 20 // Note: 24 midi channels is the minimum general midi - // spec implementation - -#else // Simulator requires 44100, and we can afford to use more voices - -#define SAMPLE_RATE SAMPR_44 -#define MAX_VOICES 48 - -#endif - - -#define BUF_SIZE 256 -#define NBUF 2 - #undef SYNC #ifdef SIMULATOR @@ -114,13 +92,6 @@ struct MIDIfile * mf IBSS_ATTR; int numberOfSamples IBSS_ATTR; long bpm IBSS_ATTR; -#include "midi/midiutil.c" -#include "midi/guspat.h" -#include "midi/guspat.c" -#include "midi/sequencer.c" -#include "midi/midifile.c" -#include "midi/synth.c" - long gmbuf[BUF_SIZE*NBUF]; int quit=0; diff --git a/apps/plugins/midi/midiutil.c b/apps/plugins/midi/midiutil.c index 0607c1ab3c..7cb128fb84 100644 --- a/apps/plugins/midi/midiutil.c +++ b/apps/plugins/midi/midiutil.c @@ -5,6 +5,7 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ + * $Id$ * * Copyright (C) 2005 Stepan Moskovchenko * @@ -15,134 +16,23 @@ * KIND, either express or implied. * ****************************************************************************/ - - -#define BYTE unsigned char - -//Data chunk ID types, returned by readID() -#define ID_UNKNOWN -1 -#define ID_MTHD 1 -#define ID_MTRK 2 -#define ID_EOF 3 -#define ID_RIFF 4 - - -//MIDI Commands -#define MIDI_NOTE_OFF 128 -#define MIDI_NOTE_ON 144 -#define MIDI_AFTERTOUCH 160 -#define MIDI_CONTROL 176 -#define MIDI_PRGM 192 -#define MIDI_PITCHW 224 - - -//MIDI Controllers -#define CTRL_VOLUME 7 -#define CTRL_BALANCE 8 -#define CTRL_PANNING 10 -#define CHANNEL 1 - -//Most of these are deprecated.. rampdown is used, maybe one other one too -#define STATE_ATTACK 1 -#define STATE_DECAY 2 -#define STATE_SUSTAIN 3 -#define STATE_RELEASE 4 -#define STATE_RAMPDOWN 5 - -//Loop states -#define STATE_LOOPING 7 -#define STATE_NONLOOPING 8 - -//Various bits in the GUS mode byte -#define LOOP_ENABLED 4 -#define LOOP_PINGPONG 8 -#define LOOP_REVERSE 16 - -#define LOOPDIR_FORWARD 0 -#define LOOPDIR_REVERSE 1 - +#include "plugin.h" +#include "midiutil.h" extern struct plugin_api * rb; -int printf(const char *fmt, ...); - int chVol[16] IBSS_ATTR; /* Channel volume */ int chPanLeft[16] IBSS_ATTR; /* Channel panning */ int chPanRight[16] IBSS_ATTR; int chPat[16] IBSS_ATTR; /* Channel patch */ int chPW[16] IBSS_ATTR; /* Channel pitch wheel, MSB only */ - struct GPatch * gusload(char *); struct GPatch * patchSet[128]; struct GPatch * drumSet[128]; -struct Event -{ - unsigned int delta; - unsigned char status, d1, d2; - unsigned int len; - unsigned char * evData; -}; - -struct Track -{ - unsigned int size; - unsigned int numEvents; - unsigned int delta; /* For sequencing */ - unsigned int pos; /* For sequencing */ - void * dataBlock; -}; - - -struct MIDIfile -{ - int Length; - unsigned short numTracks; - unsigned short div; /* Time division, X ticks per millisecond */ - struct Track * tracks[48]; - unsigned char patches[128]; - int numPatches; -}; - -/* -struct SynthObject -{ - struct GWaveform * wf; - unsigned int delta; - unsigned int decay; - unsigned int cp; - unsigned char state, loopState, loopDir; - unsigned char note, vol, ch, isUsed; - int curRate, curOffset, targetOffset; - unsigned int curPoint; -}; -*/ - -struct SynthObject -{ - struct GWaveform * wf; - int delta; - int decay; - unsigned int cp; /* unsigned int */ - int state, loopState, loopDir; - int note, vol, ch, isUsed; - int curRate, curOffset, targetOffset; - int curPoint; - signed short int volscale; -}; - struct SynthObject voices[MAX_VOICES] IBSS_ATTR; -void sendEvent(struct Event * ev); -inline void setPoint(struct SynthObject * so, int pt); -struct Event * getEvent(struct Track * tr, int evNum); -int readTwoBytes(int file); -int readFourBytes(int file); -int readVarData(int file); -int midimain(void * filename); - - void *alloc(int size) { static char *offset = NULL; @@ -180,7 +70,6 @@ void *alloc(int size) return ret; } - /* Rick's code */ /* void *alloc(int size) @@ -267,3 +156,4 @@ void exit(int code) { code = code; /* Stub function, kill warning for now */ } + diff --git a/apps/plugins/midi/midiutil.h b/apps/plugins/midi/midiutil.h new file mode 100644 index 0000000000..cfaa4fb2fe --- /dev/null +++ b/apps/plugins/midi/midiutil.h @@ -0,0 +1,172 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Stepan Moskovchenko + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#define FRACTSIZE 10 + +#define BUF_SIZE 256 +#define NBUF 2 + + +#ifndef SIMULATOR + +#if (HW_SAMPR_CAPS & SAMPR_CAP_22) +#define SAMPLE_RATE SAMPR_22 // 44100 22050 11025 +#else +#define SAMPLE_RATE SAMPR_44 // 44100 22050 11025 +#endif + +#define MAX_VOICES 20 // Note: 24 midi channels is the minimum general midi + // spec implementation + +#else // Simulator requires 44100, and we can afford to use more voices + +#define SAMPLE_RATE SAMPR_44 +#define MAX_VOICES 48 + +#endif + +#define BYTE unsigned char + +//Data chunk ID types, returned by readID() +#define ID_UNKNOWN -1 +#define ID_MTHD 1 +#define ID_MTRK 2 +#define ID_EOF 3 +#define ID_RIFF 4 + +//MIDI Commands +#define MIDI_NOTE_OFF 128 +#define MIDI_NOTE_ON 144 +#define MIDI_AFTERTOUCH 160 +#define MIDI_CONTROL 176 +#define MIDI_PRGM 192 +#define MIDI_PITCHW 224 + +//MIDI Controllers +#define CTRL_VOLUME 7 +#define CTRL_BALANCE 8 +#define CTRL_PANNING 10 +#define CHANNEL 1 + +//Most of these are deprecated.. rampdown is used, maybe one other one too +#define STATE_ATTACK 1 +#define STATE_DECAY 2 +#define STATE_SUSTAIN 3 +#define STATE_RELEASE 4 +#define STATE_RAMPDOWN 5 + +//Loop states +#define STATE_LOOPING 7 +#define STATE_NONLOOPING 8 + +//Various bits in the GUS mode byte +#define LOOP_ENABLED 4 +#define LOOP_PINGPONG 8 +#define LOOP_REVERSE 16 + +#define LOOPDIR_FORWARD 0 +#define LOOPDIR_REVERSE 1 + +struct MIDIfile +{ + int Length; + unsigned short numTracks; + unsigned short div; /* Time division, X ticks per millisecond */ + struct Track * tracks[48]; + unsigned char patches[128]; + int numPatches; +}; + +/* +struct SynthObject +{ + struct GWaveform * wf; + unsigned int delta; + unsigned int decay; + unsigned int cp; + unsigned char state, loopState, loopDir; + unsigned char note, vol, ch, isUsed; + int curRate, curOffset, targetOffset; + unsigned int curPoint; +}; +*/ + +struct SynthObject +{ + struct GWaveform * wf; + int delta; + int decay; + unsigned int cp; /* unsigned int */ + int state, loopState, loopDir; + int note, vol, ch, isUsed; + int curRate, curOffset, targetOffset; + int curPoint; + signed short int volscale; +}; + +struct Event +{ + unsigned int delta; + unsigned char status, d1, d2; + unsigned int len; + unsigned char * evData; +}; + +struct Track +{ + unsigned int size; + unsigned int numEvents; + unsigned int delta; /* For sequencing */ + unsigned int pos; /* For sequencing */ + void * dataBlock; +}; + +int printf(const char *fmt, ...); +int midimain(void * filename); +unsigned char readChar(int file); +void sendEvent(struct Event * ev); +inline void setPoint(struct SynthObject * so, int pt); +struct Event * getEvent(struct Track * tr, int evNum); +int readTwoBytes(int file); +int readFourBytes(int file); +int readVarData(int file); +int eof(int fd); +unsigned char * readData(int file, int len); +void exit(int code); + +#define malloc(n) my_malloc(n) +void * my_malloc(int size); + +extern struct SynthObject voices[MAX_VOICES]; + +extern int chVol[16]; /* Channel volume */ +extern int chPanLeft[16]; /* Channel panning */ +extern int chPanRight[16]; +extern int chPat[16]; /* Channel patch */ +extern int chPW[16]; /* Channel pitch wheel, MSB only */ + +extern struct GPatch * gusload(char *); +extern struct GPatch * patchSet[128]; +extern struct GPatch * drumSet[128]; + +extern struct MIDIfile * mf; + +extern int numberOfSamples; +extern long bpm; + diff --git a/apps/plugins/midi/sequencer.c b/apps/plugins/midi/sequencer.c index 68c29f35ad..473b7e4e2c 100644 --- a/apps/plugins/midi/sequencer.c +++ b/apps/plugins/midi/sequencer.c @@ -5,6 +5,7 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ + * $Id$ * * Copyright (C) 2005 Stepan Moskovchenko * @@ -15,6 +16,9 @@ * KIND, either express or implied. * ****************************************************************************/ +#include "plugin.h" +#include "midiutil.h" +#include "guspat.h" void setVolScale(int a); @@ -22,7 +26,6 @@ extern struct plugin_api * rb; long tempo=375000; - inline void setVol(int ch, int vol) { int a=0; @@ -119,7 +122,6 @@ long pitchTbl[] ICONST_ATTR={ 73297,73330,73363,73396,73429,73462,73495,73528 }; - void findDelta(struct SynthObject * so, int ch, int note) { @@ -147,7 +149,6 @@ inline void setPW(int ch, int msb, int lsb) } } - /* Sets the volume scaling by channel volume and note volume */ /* This way we can do the multiplication/indexing once per */ /* MIDI event at the most, instead of once per sample. */ @@ -375,3 +376,4 @@ int tick(void) else return 0; } + diff --git a/apps/plugins/midi/sequencer.h b/apps/plugins/midi/sequencer.h new file mode 100644 index 0000000000..cfa81f99c6 --- /dev/null +++ b/apps/plugins/midi/sequencer.h @@ -0,0 +1,23 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Stepan Moskovchenko + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +int tick(void); + +extern long tempo; + diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c index 00a01e41cb..917a8ae13d 100644 --- a/apps/plugins/midi/synth.c +++ b/apps/plugins/midi/synth.c @@ -5,6 +5,7 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ + * $Id$ * * Copyright (C) 2005 Stepan Moskovchenko * @@ -15,6 +16,10 @@ * KIND, either express or implied. * ****************************************************************************/ +#include "plugin.h" +#include "guspat.h" +#include "midiutil.h" +#include "synth.h" extern struct plugin_api * rb; @@ -43,8 +48,6 @@ void readTextBlock(int file, char * buf) rb->lseek(file, -1, SEEK_CUR); } - - /* Filename is the name of the config file */ /* The MIDI file should have been loaded at this point */ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) @@ -400,34 +403,3 @@ signed short int synthVoice(struct SynthObject * so) return s*so->volscale>>14; } - - - - -inline void synthSample(int * mixL, int * mixR) -{ - register int dL=0; - register int dR=0; - register short sample=0; - register struct SynthObject *voicept=voices; - struct SynthObject *lastvoice=&voices[MAX_VOICES]; - - while(voicept!=lastvoice) - { - if(voicept->isUsed==1) - { - sample = synthVoice(voicept); - dL += (sample*chPanLeft[voicept->ch])>>7; - dR += (sample*chPanRight[voicept->ch])>>7; - } - voicept++; - } - - *mixL=dL; - *mixR=dR; - - /* TODO: Automatic Gain Control, anyone? */ - /* Or, should this be implemented on the DSP's output volume instead? */ - - return; /* No more ghetto lowpass filter.. linear intrpolation works well. */ -} diff --git a/apps/plugins/midi/synth.h b/apps/plugins/midi/synth.h new file mode 100644 index 0000000000..daaf26d5f6 --- /dev/null +++ b/apps/plugins/midi/synth.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Stepan Moskovchenko + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig); +signed short int synthVoice(struct SynthObject * so); + +static inline void synthSample(int * mixL, int * mixR) +{ + register int dL=0; + register int dR=0; + register short sample=0; + register struct SynthObject *voicept=voices; + struct SynthObject *lastvoice=&voices[MAX_VOICES]; + + while(voicept!=lastvoice) + { + if(voicept->isUsed==1) + { + sample = synthVoice(voicept); + dL += (sample*chPanLeft[voicept->ch])>>7; + dR += (sample*chPanRight[voicept->ch])>>7; + } + voicept++; + } + + *mixL=dL; + *mixR=dR; + + /* TODO: Automatic Gain Control, anyone? */ + /* Or, should this be implemented on the DSP's output volume instead? */ + + return; /* No more ghetto lowpass filter.. linear intrpolation works well. */ +} +