Skip to content

Commit 6d9756f

Browse files
author
dashodanger
committed
Emu de MIDI tweaks
1 parent 6d8643f commit 6d9756f

File tree

8 files changed

+23
-36
lines changed

8 files changed

+23
-36
lines changed

libraries/libemidi/source/CEnvelope.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
#include "CEnvelope.hpp"
22

3-
#if defined(_MSC_VER)
4-
#if defined(_DEBUG)
5-
#define new new (_CLIENT_BLOCK, __FILE__, __LINE__)
6-
#endif
7-
#endif
8-
93
using namespace dsa;
104

115
#define GETA_BITS 20

libraries/libemidi/source/CMIDIModule.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
#include "CMIDIModule.hpp"
22

3-
#if defined(_MSC_VER)
4-
#if defined(_DEBUG)
5-
#define new new (_NORMAL_BLOCK, __FILE__, __LINE__)
6-
#endif
7-
#endif
8-
93
using namespace dsa;
104

115
CMIDIModule::CMIDIModule() : m_device(NULL)

libraries/libemidi/source/COpllDevice.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55

66
#include <cstdio>
77

8-
#if defined(_MSC_VER)
9-
#if defined(_DEBUG)
10-
#define new new (_NORMAL_BLOCK, __FILE__, __LINE__)
11-
#endif
12-
#endif
13-
148
using namespace dsa;
159
using namespace dsa::C;
1610

@@ -87,7 +81,11 @@ COpllDevice::COpllDevice(uint32_t rate, uint32_t nch)
8781
m_nch = 1;
8882

8983
for (uint32_t i = 0; i < m_nch; i++)
84+
{
9085
m_opll[i] = OPLL_new(3579545, rate);
86+
memset(m_reg_cache[i],0,128);
87+
m_rbuf[i].clear();
88+
}
9189
Reset();
9290
}
9391

@@ -344,25 +342,27 @@ void COpllDevice::PercSetVelocity(uint8_t note, uint8_t velo)
344342
{
345343
note = perc_table[note];
346344
if (0 < note)
345+
{
347346
m_pi.velocity[note - 1] = velo;
348-
_PercUpdateVolume(note);
347+
_PercUpdateVolume(note);
348+
}
349349
}
350350

351351
void COpllDevice::_PercUpdateVolume(uint8_t note)
352352
{
353353

354-
if (note > 5)
354+
if (note < 1 || note > 5)
355355
return;
356356

357-
int vol = 13 - m_pi.volume / 16 - m_pi.velocity[note] / 16;
357+
int vol = 13 - m_pi.volume / 16 - m_pi.velocity[note-1] / 16;
358358
if (vol < 0)
359-
m_pi.vcache[note] = 0;
359+
m_pi.vcache[note-1] = 0;
360360
else if (15 < vol)
361-
m_pi.vcache[note] = 15;
361+
m_pi.vcache[note-1] = 15;
362362
else
363-
m_pi.vcache[note] = vol;
363+
m_pi.vcache[note-1] = vol;
364364

365-
switch (note)
365+
switch (note-1)
366366
{
367367
case 4: // B.D
368368
_WriteReg(0x30 + 6, m_pi.vcache[4]);
@@ -389,7 +389,7 @@ void COpllDevice::PercSetProgram(uint8_t bank, uint8_t prog)
389389
void COpllDevice::PercSetVolume(uint8_t vol)
390390
{
391391
m_pi.volume = vol;
392-
for (int i = 0; i < 5; i++)
392+
for (int i = 1; i < 6; i++)
393393
_PercUpdateVolume(i);
394394
}
395395

libraries/libemidi/source/CPSGDrum.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ bool CPSGDrum::Render(int32_t buf[2])
119119
}
120120
}
121121
else
122+
{
122123
buf[0] += m_rbuf[i].front();
123-
m_rbuf[i].pop_front();
124+
m_rbuf[i].pop_front();
125+
}
124126
}
125127
buf[0] <<= 1;
126128
buf[1] = buf[0];

libraries/libemidi/source/CSMFPlay.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <limits.h>
33
#include "CSMFPlay.hpp"
44
#include "COpllDevice.hpp"
5+
#include "CPSGDrum.hpp"
56
#include "CSccDevice.hpp"
67

78
using namespace dsa;

libraries/libemidi/source/CSccDevice.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
#include <math.h>
55
#include <string.h>
66

7-
#if defined(_MSC_VER)
8-
#if defined(_DEBUG)
9-
#define new new (_CLIENT_BLOCK, __FILE__, __LINE__)
10-
#endif
11-
#endif
12-
137
using namespace dsa;
148
using namespace dsa::C;
159

@@ -155,7 +149,7 @@ bool CSccDevice::Reset(void)
155149
{
156150
SCC_reset(m_scc[i]);
157151
SCC_set_type(m_scc[i], SCC_ENHANCED);
158-
memset(m_reg_cache[i], 0, 128);
152+
memset(m_reg_cache[i],0,256);
159153
m_rbuf[i].clear();
160154
}
161155
}

libraries/libemidi/source/device/emu2212.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,10 @@ EMU2212_API void SCC_calc_stereo(SCC *scc, e_int16 buf[2])
524524
else if (scc->ch_pan[i] == 2)
525525
buf[1] += b;
526526
else
527+
{
527528
buf[0] += b;
528-
buf[1] += b;
529+
buf[1] += b;
530+
}
529531
}
530532
}
531533
}

source_files/edge/s_emidi.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class EMIDIPlayer : public AbstractMusicPlayer
123123
static void rtPitchBend(void *userdata, uint8_t channel, uint8_t msb, uint8_t lsb)
124124
{
125125
EMIDIPlayer *player = (EMIDIPlayer *)userdata;
126-
player->emidi_synth_->SendMIDIMessage({dsa::CMIDIMsg::PITCH_BEND_CHANGE, channel, msb, lsb});
126+
player->emidi_synth_->SendMIDIMessage({dsa::CMIDIMsg::PITCH_BEND_CHANGE, channel, lsb, msb});
127127
}
128128

129129
static void rtSysEx(void *userdata, const uint8_t *msg, size_t size)

0 commit comments

Comments
 (0)