Skip to content

Commit

Permalink
Emu de MIDI tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Oct 23, 2024
1 parent 6d8643f commit 6d9756f
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 36 deletions.
6 changes: 0 additions & 6 deletions libraries/libemidi/source/CEnvelope.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#include "CEnvelope.hpp"

#if defined(_MSC_VER)
#if defined(_DEBUG)
#define new new (_CLIENT_BLOCK, __FILE__, __LINE__)
#endif
#endif

using namespace dsa;

#define GETA_BITS 20
Expand Down
6 changes: 0 additions & 6 deletions libraries/libemidi/source/CMIDIModule.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#include "CMIDIModule.hpp"

#if defined(_MSC_VER)
#if defined(_DEBUG)
#define new new (_NORMAL_BLOCK, __FILE__, __LINE__)
#endif
#endif

using namespace dsa;

CMIDIModule::CMIDIModule() : m_device(NULL)
Expand Down
28 changes: 14 additions & 14 deletions libraries/libemidi/source/COpllDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@

#include <cstdio>

#if defined(_MSC_VER)
#if defined(_DEBUG)
#define new new (_NORMAL_BLOCK, __FILE__, __LINE__)
#endif
#endif

using namespace dsa;
using namespace dsa::C;

Expand Down Expand Up @@ -87,7 +81,11 @@ COpllDevice::COpllDevice(uint32_t rate, uint32_t nch)
m_nch = 1;

for (uint32_t i = 0; i < m_nch; i++)
{
m_opll[i] = OPLL_new(3579545, rate);
memset(m_reg_cache[i],0,128);
m_rbuf[i].clear();
}
Reset();
}

Expand Down Expand Up @@ -344,25 +342,27 @@ void COpllDevice::PercSetVelocity(uint8_t note, uint8_t velo)
{
note = perc_table[note];
if (0 < note)
{
m_pi.velocity[note - 1] = velo;
_PercUpdateVolume(note);
_PercUpdateVolume(note);
}
}

void COpllDevice::_PercUpdateVolume(uint8_t note)
{

if (note > 5)
if (note < 1 || note > 5)
return;

int vol = 13 - m_pi.volume / 16 - m_pi.velocity[note] / 16;
int vol = 13 - m_pi.volume / 16 - m_pi.velocity[note-1] / 16;
if (vol < 0)
m_pi.vcache[note] = 0;
m_pi.vcache[note-1] = 0;
else if (15 < vol)
m_pi.vcache[note] = 15;
m_pi.vcache[note-1] = 15;
else
m_pi.vcache[note] = vol;
m_pi.vcache[note-1] = vol;

switch (note)
switch (note-1)
{
case 4: // B.D
_WriteReg(0x30 + 6, m_pi.vcache[4]);
Expand All @@ -389,7 +389,7 @@ void COpllDevice::PercSetProgram(uint8_t bank, uint8_t prog)
void COpllDevice::PercSetVolume(uint8_t vol)
{
m_pi.volume = vol;
for (int i = 0; i < 5; i++)
for (int i = 1; i < 6; i++)
_PercUpdateVolume(i);
}

Expand Down
4 changes: 3 additions & 1 deletion libraries/libemidi/source/CPSGDrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ bool CPSGDrum::Render(int32_t buf[2])
}
}
else
{
buf[0] += m_rbuf[i].front();
m_rbuf[i].pop_front();
m_rbuf[i].pop_front();
}
}
buf[0] <<= 1;
buf[1] = buf[0];
Expand Down
1 change: 1 addition & 0 deletions libraries/libemidi/source/CSMFPlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <limits.h>
#include "CSMFPlay.hpp"
#include "COpllDevice.hpp"
#include "CPSGDrum.hpp"
#include "CSccDevice.hpp"

using namespace dsa;
Expand Down
8 changes: 1 addition & 7 deletions libraries/libemidi/source/CSccDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
#include <math.h>
#include <string.h>

#if defined(_MSC_VER)
#if defined(_DEBUG)
#define new new (_CLIENT_BLOCK, __FILE__, __LINE__)
#endif
#endif

using namespace dsa;
using namespace dsa::C;

Expand Down Expand Up @@ -155,7 +149,7 @@ bool CSccDevice::Reset(void)
{
SCC_reset(m_scc[i]);
SCC_set_type(m_scc[i], SCC_ENHANCED);
memset(m_reg_cache[i], 0, 128);
memset(m_reg_cache[i],0,256);
m_rbuf[i].clear();
}
}
Expand Down
4 changes: 3 additions & 1 deletion libraries/libemidi/source/device/emu2212.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,10 @@ EMU2212_API void SCC_calc_stereo(SCC *scc, e_int16 buf[2])
else if (scc->ch_pan[i] == 2)
buf[1] += b;
else
{
buf[0] += b;
buf[1] += b;
buf[1] += b;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source_files/edge/s_emidi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class EMIDIPlayer : public AbstractMusicPlayer
static void rtPitchBend(void *userdata, uint8_t channel, uint8_t msb, uint8_t lsb)
{
EMIDIPlayer *player = (EMIDIPlayer *)userdata;
player->emidi_synth_->SendMIDIMessage({dsa::CMIDIMsg::PITCH_BEND_CHANGE, channel, msb, lsb});
player->emidi_synth_->SendMIDIMessage({dsa::CMIDIMsg::PITCH_BEND_CHANGE, channel, lsb, msb});
}

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

0 comments on commit 6d9756f

Please sign in to comment.