123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #ifndef H_ADPLUG_DEMUOPL
- #define H_ADPLUG_DEMUOPL
- #include "opl.h"
- #include "dosbox_opl.h"
- #include <assert.h>
- class CDemuopl: public Copl
- {
- public:
- CDemuopl(int rate, bool bit16, bool usestereo)
- :use16bit(bit16), stereo(usestereo)
- {
- adlib_init(rate);
- currType = TYPE_OPL2;
- };
- void update(short *buf, int samples)
- {
- short *mixbuf0 = new short[samples*2],*mixbuf1 = new short[samples*2];
- short *outbuf;
- if(use16bit) outbuf = buf;
- else outbuf = mixbuf1;
-
-
- adlib_getsample(outbuf, samples);
- if(stereo)
- for(int i=samples-1;i>=0;i--) {
- outbuf[i*2] = outbuf[i];
- outbuf[i*2+1] = outbuf[i];
- }
-
- if(!use16bit)
- for(int i=0;i<(stereo ? samples*2 : samples);i++)
- ((char *)buf)[i] = (outbuf[i] >> 8) ^ 0x80;
- delete[] mixbuf0; delete[] mixbuf1;
- }
-
- void write(int reg, int val)
- {
- if(currChip == 0)
- adlib_write(reg, val);
- };
- void init() {};
- protected:
- bool use16bit,stereo;
- };
- #endif
|