diff --git a/src/engine/fileOps.cpp b/src/engine/fileOps.cpp index 8d3dd476..c689fdc8 100644 --- a/src/engine/fileOps.cpp +++ b/src/engine/fileOps.cpp @@ -1476,7 +1476,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) { sample->loopMode=DIV_SAMPLE_LOOPMODE_ONESHOT; sample->loopStart=0; } else { - sample->loopMode=DIV_SAMPLE_LOOPMODE_FOWARD; + sample->loopMode=DIV_SAMPLE_LOOPMODE_FORWARD; } } else { reader.readI(); @@ -1714,7 +1714,7 @@ bool DivEngine::loadMod(unsigned char* file, size_t len) { sample->loopMode=DIV_SAMPLE_LOOPMODE_ONESHOT; sample->loopStart=0; } else { - sample->loopMode=DIV_SAMPLE_LOOPMODE_FOWARD; + sample->loopMode=DIV_SAMPLE_LOOPMODE_FORWARD; } } sample->init(slen); diff --git a/src/engine/platform/es5506.cpp b/src/engine/platform/es5506.cpp index c94fdf41..ee3f45e8 100644 --- a/src/engine/platform/es5506.cpp +++ b/src/engine/platform/es5506.cpp @@ -168,7 +168,7 @@ void DivPlatformES5506::acquire(short* bufL, short* bufR, size_t start, size_t l } } -void DivPlatformES5506::e(bool state) +void DivPlatformES5506::e_pin(bool state) { if (es5506.e_rising_edge()) { if (cycle) { // wait until delay @@ -292,6 +292,7 @@ void DivPlatformES5506::tick(bool sysTick) { chan[i].k1Offs=chan[i].std.ex1.val; chan[i].filterChanged.k1=1; } + break; case 1: // absolute if (chan[i].filter.k1!=(chan[i].std.ex1.val&0xffff)) { chan[i].filter.k1=chan[i].std.ex1.val&0xffff; @@ -317,6 +318,7 @@ void DivPlatformES5506::tick(bool sysTick) { chan[i].k2Offs=chan[i].std.ex1.val; chan[i].filterChanged.k2=1; } + break; case 1: // absolute if (chan[i].filter.k2!=(chan[i].std.ex2.val&0xffff)) { chan[i].filter.k2=chan[i].std.ex2.val&0xffff; @@ -472,7 +474,7 @@ void DivPlatformES5506::tick(bool sysTick) { case DIV_SAMPLE_LOOPMODE_ONESHOT: // One shot (no loop) default: break; - case DIV_SAMPLE_LOOPMODE_FOWARD: // Foward loop + case DIV_SAMPLE_LOOPMODE_FORWARD: // Foward loop loopFlag|=0x0008; break; case DIV_SAMPLE_LOOPMODE_BACKWARD: // Backward loop: IRQ enable @@ -728,8 +730,8 @@ void DivPlatformES5506::forceIns() { chan[i].insChanged=true; chan[i].freqChanged=true; chan[i].volChanged=true; - chan[i].filterChanged.changed=(unsigned char)(~0); - chan[i].envChanged.changed=(unsigned char)(~0); + chan[i].filterChanged.changed=0xff; + chan[i].envChanged.changed=0xff; chan[i].sample=-1; } } diff --git a/src/engine/platform/es5506.h b/src/engine/platform/es5506.h index d378a19f..fc49525f 100644 --- a/src/engine/platform/es5506.h +++ b/src/engine/platform/es5506.h @@ -165,7 +165,7 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf { friend void putDispatchChan(void*,int,int); public: - virtual void e(bool state) override; // E output + virtual void e_pin(bool state) override; // E output virtual void irqb(bool state) override; // IRQB output virtual s16 read_sample(u8 voice, u8 bank, u32 address) override { diff --git a/src/engine/platform/sound/es550x/es5504.cpp b/src/engine/platform/sound/es550x/es5504.cpp index d9750b7f..00707d4f 100644 --- a/src/engine/platform/sound/es550x/es5504.cpp +++ b/src/engine/platform/sound/es550x/es5504.cpp @@ -32,7 +32,7 @@ void es5504_core::tick() { if (m_e.tick()) { - m_intf.e(m_e.current_edge()); + m_intf.e_pin(m_e.current_edge()); if (m_e.rising_edge()) // Host access { m_host_intf.m_rw = m_host_intf.m_rw_strobe; @@ -77,24 +77,24 @@ void es5504_core::tick_perf() // update // falling edge m_e.m_edge.set(false); - m_intf.e(false); + m_intf.e_pin(false); m_host_intf.m_host_access = m_host_intf.m_host_access_strobe = false; m_voice[m_voice_cycle].fetch(m_voice_cycle, m_voice_fetch); voice_tick(); // rising edge m_e.m_edge.set(true); - m_intf.e(true); + m_intf.e_pin(true); m_host_intf.m_rw = m_host_intf.m_rw_strobe; m_host_intf.m_host_access = m_host_intf.m_host_access_strobe; // falling edge m_e.m_edge.set(false); - m_intf.e(false); + m_intf.e_pin(false); m_host_intf.m_host_access = m_host_intf.m_host_access_strobe = false; m_voice[m_voice_cycle].fetch(m_voice_cycle, m_voice_fetch); voice_tick(); // rising edge m_e.m_edge.set(true); - m_intf.e(true); + m_intf.e_pin(true); m_host_intf.m_rw = m_host_intf.m_rw_strobe; m_host_intf.m_host_access = m_host_intf.m_host_access_strobe; } diff --git a/src/engine/platform/sound/es550x/es5505.cpp b/src/engine/platform/sound/es550x/es5505.cpp index ca5fb890..d2d4731c 100644 --- a/src/engine/platform/sound/es550x/es5505.cpp +++ b/src/engine/platform/sound/es550x/es5505.cpp @@ -63,7 +63,7 @@ void es5505_core::tick() for (int i = 0; i < 4; i++) { if (m_wclk_lr) // Right output - m_output_temp[i].m_right = (m_output_temp[i].m_left << 1) | bitfield(m_output_latch[i].m_right, output_bit); + m_output_temp[i].m_right = (m_output_temp[i].m_right << 1) | bitfield(m_output_latch[i].m_right, output_bit); else // Left output m_output_temp[i].m_left = (m_output_temp[i].m_left << 1) | bitfield(m_output_latch[i].m_left, output_bit); } @@ -89,7 +89,7 @@ void es5505_core::tick() // E if (m_e.tick()) { - m_intf.e(m_e.current_edge()); + m_intf.e_pin(m_e.current_edge()); if (m_e.rising_edge()) // Host access { m_host_intf.m_rw = m_host_intf.m_rw_strobe; @@ -141,24 +141,24 @@ void es5505_core::tick_perf() // update // falling edge m_e.m_edge.set(false); - m_intf.e(false); + m_intf.e_pin(false); m_host_intf.m_host_access = m_host_intf.m_host_access_strobe = false; m_voice[m_voice_cycle].fetch(m_voice_cycle, m_voice_fetch); voice_tick(); // rising edge m_e.m_edge.set(true); - m_intf.e(true); + m_intf.e_pin(true); m_host_intf.m_rw = m_host_intf.m_rw_strobe; m_host_intf.m_host_access = m_host_intf.m_host_access_strobe; // falling edge m_e.m_edge.set(false); - m_intf.e(false); + m_intf.e_pin(false); m_host_intf.m_host_access = m_host_intf.m_host_access_strobe = false; m_voice[m_voice_cycle].fetch(m_voice_cycle, m_voice_fetch); voice_tick(); // rising edge m_e.m_edge.set(true); - m_intf.e(true); + m_intf.e_pin(true); m_host_intf.m_rw = m_host_intf.m_rw_strobe; m_host_intf.m_host_access = m_host_intf.m_host_access_strobe; } diff --git a/src/engine/platform/sound/es550x/es5505.hpp b/src/engine/platform/sound/es550x/es5505.hpp index be6505f6..1803e7d8 100644 --- a/src/engine/platform/sound/es550x/es5505.hpp +++ b/src/engine/platform/sound/es550x/es5505.hpp @@ -131,7 +131,7 @@ private: clock_pulse_t m_lrclk; // LRCLK s16 m_wclk = 0; // WCLK bool m_wclk_lr = false; // WCLK, L/R output select - u8 m_output_bit = 0; // Bit position in output + s8 m_output_bit = 0; // Bit position in output output_t m_ch[4]; // 4 stereo output channels output_t m_output[4]; // Serial outputs output_t m_output_temp[4]; // temporary signal for serial output diff --git a/src/engine/platform/sound/es550x/es5506.cpp b/src/engine/platform/sound/es550x/es5506.cpp index d1ac89bb..133611ee 100644 --- a/src/engine/platform/sound/es550x/es5506.cpp +++ b/src/engine/platform/sound/es550x/es5506.cpp @@ -83,7 +83,7 @@ void es5506_core::tick() for (int i = 0; i < 6; i++) { if (m_wclk_lr) // Right output - m_output_temp[i].m_right = (m_output_temp[i].m_left << 1) | bitfield(m_output_latch[i].m_right, output_bit); + m_output_temp[i].m_right = (m_output_temp[i].m_right << 1) | bitfield(m_output_latch[i].m_right, output_bit); else // Left output m_output_temp[i].m_left = (m_output_temp[i].m_left << 1) | bitfield(m_output_latch[i].m_left, output_bit); } @@ -124,7 +124,7 @@ void es5506_core::tick() // E if (m_e.tick()) { - m_intf.e(m_e.current_edge()); + m_intf.e_pin(m_e.current_edge()); if (m_e.rising_edge()) { m_host_intf.m_rw = m_host_intf.m_rw_strobe; @@ -190,24 +190,24 @@ void es5506_core::tick_perf() // update // falling edge m_e.m_edge.set(false); - m_intf.e(false); + m_intf.e_pin(false); m_host_intf.m_host_access = m_host_intf.m_host_access_strobe = false; m_voice[m_voice_cycle].fetch(m_voice_cycle, m_voice_fetch); voice_tick(); // rising edge m_e.m_edge.set(true); - m_intf.e(true); + m_intf.e_pin(true); m_host_intf.m_rw = m_host_intf.m_rw_strobe; m_host_intf.m_host_access = m_host_intf.m_host_access_strobe; // falling edge m_e.m_edge.set(false); - m_intf.e(false); + m_intf.e_pin(false); m_host_intf.m_host_access = m_host_intf.m_host_access_strobe = false; m_voice[m_voice_cycle].fetch(m_voice_cycle, m_voice_fetch); voice_tick(); // rising edge m_e.m_edge.set(true); - m_intf.e(true); + m_intf.e_pin(true); m_host_intf.m_rw = m_host_intf.m_rw_strobe; m_host_intf.m_host_access = m_host_intf.m_host_access_strobe; } diff --git a/src/engine/platform/sound/es550x/es5506.hpp b/src/engine/platform/sound/es550x/es5506.hpp index 2232f517..f46941ed 100644 --- a/src/engine/platform/sound/es550x/es5506.hpp +++ b/src/engine/platform/sound/es550x/es5506.hpp @@ -169,7 +169,7 @@ private: clock_pulse_t m_lrclk; // LRCLK s16 m_wclk = 0; // WCLK bool m_wclk_lr = false; // WCLK, L/R output select - u8 m_output_bit = 0; // Bit position in output + s8 m_output_bit = 0; // Bit position in output output_t m_ch[6]; // 6 stereo output channels output_t m_output[6]; // Serial outputs output_t m_output_temp[6]; // temporary signal for serial output diff --git a/src/engine/platform/sound/es550x/es550x.hpp b/src/engine/platform/sound/es550x/es550x.hpp index eb3eaf25..4c7a8fa7 100644 --- a/src/engine/platform/sound/es550x/es550x.hpp +++ b/src/engine/platform/sound/es550x/es550x.hpp @@ -146,7 +146,7 @@ using namespace es550x; class es550x_intf { public: - virtual void e(bool state) {} // E output + virtual void e_pin(bool state) {} // E output virtual void bclk(bool state) {} // BCLK output (serial specific) virtual void lrclk(bool state) {} // LRCLK output (serial specific) virtual void wclk(bool state) {} // WCLK output (serial specific) diff --git a/src/engine/platform/sound/es550x/es550x_filter.cpp b/src/engine/platform/sound/es550x/es550x_filter.cpp index 8ef526ff..abf16b4d 100644 --- a/src/engine/platform/sound/es550x/es550x_filter.cpp +++ b/src/engine/platform/sound/es550x/es550x_filter.cpp @@ -26,8 +26,8 @@ void es550x_shared_core::es550x_filter_t::reset() void es550x_shared_core::es550x_filter_t::tick(s32 in) { - s32 coeff_k1 = s32(bitfield(m_k1,4,12)); // 12 MSB used - s32 coeff_k2 = s32(bitfield(m_k2,4,12)); // 12 MSB used + s32 coeff_k1 = s32(bitfield(m_k1, 4, 12)); // 12 MSB used + s32 coeff_k2 = s32(bitfield(m_k2, 4, 12)); // 12 MSB used // Store previous filter data m_o2_2 = m_o2_1; m_o3_2 = m_o3_1; @@ -43,16 +43,16 @@ void es550x_shared_core::es550x_filter_t::tick(s32 in) m_o4_1 = hp_exec(coeff_k2, m_o3_1, m_o4_1, m_o3_2); break; case 1: // LP3 = 0, LP4 = 1: HP/K2, LP/K1 - m_o4_1 = lp_exec(coeff_k1, m_o2_1, m_o3_1); - m_o3_1 = hp_exec(coeff_k2, m_o3_1, m_o4_1, m_o3_2); + m_o3_1 = lp_exec(coeff_k1, m_o2_1, m_o3_1); + m_o4_1 = hp_exec(coeff_k2, m_o3_1, m_o4_1, m_o3_2); break; case 2: // LP3 = 1, LP4 = 0: LP/K2, LP/K2 m_o3_1 = lp_exec(coeff_k2, m_o2_1, m_o3_1); m_o4_1 = lp_exec(coeff_k2, m_o3_1, m_o4_1); break; case 3: // LP3 = 1, LP4 = 1: LP/K2, LP/K1 - m_o4_1 = lp_exec(coeff_k1, m_o2_1, m_o3_1); - m_o3_1 = lp_exec(coeff_k2, m_o3_1, m_o4_1); + m_o3_1 = lp_exec(coeff_k1, m_o2_1, m_o3_1); + m_o4_1 = lp_exec(coeff_k2, m_o3_1, m_o4_1); break; } } @@ -66,5 +66,5 @@ s32 es550x_shared_core::es550x_filter_t::lp_exec(s32 coeff, s32 in, s32 prev_out s32 es550x_shared_core::es550x_filter_t::hp_exec(s32 coeff, s32 in, s32 prev_out, s32 prev_in) { // Yn = Xn - Xn-1 + K*Yn-1 - return in - prev_in + ((coeff * prev_out) / 8192) * (prev_out / 2); + return in - prev_in + ((coeff * prev_out) / 8192) + (prev_out / 2); } diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index 0f7779cf..35201cae 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -1808,7 +1808,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi if (sPreview.dir) { if (s->isLoopable() && ((int)sPreview.pos)loopStart) { switch (s->loopMode) { - case DIV_SAMPLE_LOOPMODE_FOWARD: + case DIV_SAMPLE_LOOPMODE_FORWARD: sPreview.dir=false; sPreview.pos=s->loopStart+1; break; @@ -1828,7 +1828,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi } else { if (s->isLoopable() && sPreview.pos>=s->loopEnd) { switch (s->loopMode) { - case DIV_SAMPLE_LOOPMODE_FOWARD: + case DIV_SAMPLE_LOOPMODE_FORWARD: sPreview.dir=false; sPreview.pos=s->loopStart; break; @@ -1851,7 +1851,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi if (sPreview.dir) { if (s->isLoopable() && ((int)sPreview.pos)loopStart) { switch (s->loopMode) { - case DIV_SAMPLE_LOOPMODE_FOWARD: + case DIV_SAMPLE_LOOPMODE_FORWARD: sPreview.dir=false; sPreview.pos=s->loopStart+1; break; @@ -1865,18 +1865,18 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi break; case DIV_SAMPLE_LOOPMODE_ONESHOT: default: - if (sPreview.pos<0) { + if (((int)sPreview.pos)<0) { sPreview.sample=-1; } break; } - } else if (sPreview.pos<0) { + } else if (((int)sPreview.pos)<0) { sPreview.sample=-1; } } else { if (s->isLoopable() && sPreview.pos>=s->loopEnd) { switch (s->loopMode) { - case DIV_SAMPLE_LOOPMODE_FOWARD: + case DIV_SAMPLE_LOOPMODE_FORWARD: sPreview.dir=false; sPreview.pos=s->loopStart; break; diff --git a/src/engine/sample.cpp b/src/engine/sample.cpp index c971f997..fcbc370c 100644 --- a/src/engine/sample.cpp +++ b/src/engine/sample.cpp @@ -330,10 +330,11 @@ bool DivSample::insert(unsigned int pos, unsigned int length) { #define RESAMPLE_END \ if (loopStart>=0) loopStart=(double)loopStart*(r/(double)rate); \ - if (loopEnd>=0) loopEnd=(double)loopEnd*(r/(double)rate); \ + if (loopEndsamples) loopEnd=samples; \ if (depth==DIV_SAMPLE_DEPTH_16BIT) { \ delete[] oldData16; \ } else if (depth==DIV_SAMPLE_DEPTH_8BIT) { \ diff --git a/src/engine/sample.h b/src/engine/sample.h index ff3e2f7b..d14ae952 100644 --- a/src/engine/sample.h +++ b/src/engine/sample.h @@ -51,7 +51,7 @@ enum DivSampleDepth: unsigned char { enum DivSampleLoopMode: unsigned char { DIV_SAMPLE_LOOPMODE_ONESHOT=0, - DIV_SAMPLE_LOOPMODE_FOWARD, + DIV_SAMPLE_LOOPMODE_FORWARD, DIV_SAMPLE_LOOPMODE_BACKWARD, DIV_SAMPLE_LOOPMODE_PINGPONG, DIV_SAMPLE_LOOPMODE_MAX // for identify boundary diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 3c22a17c..a5de2f29 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -1111,7 +1111,7 @@ void FurnaceGUI::drawGBEnv(unsigned char vol, unsigned char len, unsigned char s if (macro.len>127) macro.len=127; \ } \ if (macroMode && macroModeMax>0) { \ - for (int m=0; m<=macroModeMax; m++) { \ + for (unsigned int m=0; m<=macroModeMax; m++) { \ if (ImGui::RadioButton(displayModeName[m],macro.mode==m)) { \ macro.mode=m; \ } \ @@ -1206,7 +1206,7 @@ void FurnaceGUI::drawGBEnv(unsigned char vol, unsigned char len, unsigned char s if (macro.len>127) macro.len=127; \ } \ if (macroMode && macroModeMax>0) { \ - for (int m=0; m<=macroModeMax; m++) { \ + for (unsigned int m=0; m<=macroModeMax; m++) { \ if (ImGui::RadioButton(displayModeName[m],macro.mode==m)) { \ macro.mode=m; \ } \ diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index 0021294e..779185af 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -137,8 +137,8 @@ void FurnaceGUI::drawSampleEdit() { if (endloopStart) { end=sample->loopStart; } - if (end>sample->samples) { - end=sample->samples; + if (end>(int)sample->samples) { + end=(int)sample->samples; } sample->loopEnd=end; updateSampleTex=true;