diff --git a/src/engine/platform/es5506.cpp b/src/engine/platform/es5506.cpp index a9e5d439..12f15740 100644 --- a/src/engine/platform/es5506.cpp +++ b/src/engine/platform/es5506.cpp @@ -296,7 +296,7 @@ void DivPlatformES5506::e_pin(bool state) DivSample* s=parent->getSample(sample); // get frequency offset double off=1.0; - double center=s->centerRate; + double center=(double)s->centerRate; if (center<1) { off=1.0; } else { @@ -710,7 +710,7 @@ void DivPlatformES5506::tick(bool sysTick) { DivSample* s=parent->getSample(sample); // get frequency offset double off=1.0; - double center=s->centerRate; + double center=(double)s->centerRate; if (center<1) { off=1.0; } else { @@ -884,33 +884,30 @@ void DivPlatformES5506::tick(bool sysTick) { if (chan[i].noteChanged.offs) { if (chan[i].pcm.freqOffs!=chan[i].pcm.nextFreqOffs) { chan[i].pcm.freqOffs=chan[i].pcm.nextFreqOffs; - const int nextFreq=NOTE_ES5506(i,chan[i].prevNote); + const int nextFreq=NOTE_ES5506(i,chan[i].currNote); if (chan[i].nextFreq!=nextFreq) { chan[i].nextFreq=nextFreq; chan[i].noteChanged.freq=1; } } - chan[i].noteChanged.offs=0; } if (chan[i].noteChanged.note) { - if (chan[i].prevNote!=chan[i].nextNote) { - chan[i].prevNote=chan[i].nextNote; + if (chan[i].currNote!=chan[i].nextNote) { + chan[i].currNote=chan[i].nextNote; const int nextFreq=NOTE_ES5506(i,chan[i].nextNote); if (chan[i].nextFreq!=nextFreq) { chan[i].nextFreq=nextFreq; chan[i].noteChanged.freq=1; } } - chan[i].noteChanged.note=0; } if (chan[i].noteChanged.freq) { if (chan[i].baseFreq!=chan[i].nextFreq) { chan[i].baseFreq=chan[i].nextFreq; chan[i].freqChanged=true; } - chan[i].noteChanged.freq=0; } - chan[i].noteChanged.dummy=0; + chan[i].noteChanged.changed=0; } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { chan[i].freq=CLAMP_VAL(parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,2,chan[i].pitch2,chipClock,chan[i].pcm.freqOffs),0,0x1ffff); @@ -1023,7 +1020,7 @@ int DivPlatformES5506::dispatch(DivCommand c) { DivSample* s=parent->getSample(sample); // get frequency offset double off=1.0; - double center=s->centerRate; + double center=(double)s->centerRate; if (center<1) { off=1.0; } else { @@ -1087,6 +1084,7 @@ int DivPlatformES5506::dispatch(DivCommand c) { if (c.value!=DIV_NOTE_NULL) { chan[c.chan].note=c.value; chan[c.chan].nextNote=chan[c.chan].note; + chan[c.chan].pcm.nextFreqOffs=chan[c.chan].pcm.freqOffs; chan[c.chan].freqChanged=true; chan[c.chan].noteChanged.changed=0xff; chan[c.chan].volChanged.changed=0xff; diff --git a/src/engine/platform/es5506.h b/src/engine/platform/es5506.h index 4c4ad341..c5c5487d 100644 --- a/src/engine/platform/es5506.h +++ b/src/engine/platform/es5506.h @@ -62,7 +62,7 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf { loopEnd(0), loopMode(DIV_SAMPLE_LOOPMODE_ONESHOT) {} } pcm; - int freq, baseFreq, nextFreq, pitch, pitch2, note, nextNote, prevNote, ins, wave; + int freq, baseFreq, nextFreq, pitch, pitch2, note, nextNote, currNote, ins, wave; unsigned int volMacroMax, panMacroMax; bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave, isReverseLoop, isTranswave, transwaveIRQ; unsigned int cr; @@ -173,7 +173,7 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf { pitch2(0), note(0), nextNote(0), - prevNote(0), + currNote(0), ins(-1), wave(-1), volMacroMax(0xffff), diff --git a/src/engine/platform/sound/es550x/es5504.cpp b/src/engine/platform/sound/es550x/es5504.cpp index b7b808ac..2ffc7ab5 100644 --- a/src/engine/platform/sound/es550x/es5504.cpp +++ b/src/engine/platform/sound/es550x/es5504.cpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Ensoniq ES5504 emulation core diff --git a/src/engine/platform/sound/es550x/es5504.hpp b/src/engine/platform/sound/es550x/es5504.hpp index b9423dfc..bbf74b2c 100644 --- a/src/engine/platform/sound/es550x/es5504.hpp +++ b/src/engine/platform/sound/es550x/es5504.hpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Ensoniq ES5504 emulation core diff --git a/src/engine/platform/sound/es550x/es5505.cpp b/src/engine/platform/sound/es550x/es5505.cpp index 7ab2321e..4a6ab898 100644 --- a/src/engine/platform/sound/es550x/es5505.cpp +++ b/src/engine/platform/sound/es550x/es5505.cpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Ensoniq ES5505 emulation core diff --git a/src/engine/platform/sound/es550x/es5505.hpp b/src/engine/platform/sound/es550x/es5505.hpp index 25c06bee..b42322f6 100644 --- a/src/engine/platform/sound/es550x/es5505.hpp +++ b/src/engine/platform/sound/es550x/es5505.hpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Ensoniq ES5504 emulation core diff --git a/src/engine/platform/sound/es550x/es5506.cpp b/src/engine/platform/sound/es550x/es5506.cpp index 41f62b31..251b158a 100644 --- a/src/engine/platform/sound/es550x/es5506.cpp +++ b/src/engine/platform/sound/es550x/es5506.cpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Ensoniq ES5506 emulation core diff --git a/src/engine/platform/sound/es550x/es5506.hpp b/src/engine/platform/sound/es550x/es5506.hpp index 3940fea4..9aaee75b 100644 --- a/src/engine/platform/sound/es550x/es5506.hpp +++ b/src/engine/platform/sound/es550x/es5506.hpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Ensoniq ES5504 emulation core diff --git a/src/engine/platform/sound/es550x/es550x.cpp b/src/engine/platform/sound/es550x/es550x.cpp index c65a1ea6..5d83fd52 100644 --- a/src/engine/platform/sound/es550x/es550x.cpp +++ b/src/engine/platform/sound/es550x/es550x.cpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Ensoniq ES5504/ES5505/ES5506 emulation core diff --git a/src/engine/platform/sound/es550x/es550x.hpp b/src/engine/platform/sound/es550x/es550x.hpp index 52aba0f8..ad02c2ff 100644 --- a/src/engine/platform/sound/es550x/es550x.hpp +++ b/src/engine/platform/sound/es550x/es550x.hpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Ensoniq ES5504/ES5505/ES5506 emulation core @@ -8,141 +8,16 @@ See es550x.cpp for more info */ -#include -#include - #ifndef _VGSOUND_EMU_ES550X_HPP #define _VGSOUND_EMU_ES550X_HPP #pragma once -namespace es550x -{ - typedef unsigned char u8; - typedef unsigned short u16; - typedef unsigned int u32; - typedef unsigned long long u64; - typedef signed char s8; - typedef signed short s16; - typedef signed int s32; - - // get bitfield, bitfield(input, position, len) - template T bitfield(T in, u8 pos, u8 len = 1) - { - return (in >> pos) & (len ? (T(1 << len) - 1) : 1); - } - - // get sign extended value, sign_ext(input, len) - template T sign_ext(T in, u8 len) - { - len = std::max(0, (8 * sizeof(T)) - len); - return T(T(in) << len) >> len; - } - - // std::clamp is only for C++17 or later; I use my own code - template T clamp(T in, T min, T max) - { - return std::min(std::max(in, min), max); - } - - template - struct clock_pulse_t - { - void reset(T init = InitWidth) - { - m_edge.reset(); - m_width = m_width_latch = m_counter = init; - m_cycle = 0; - } - - bool tick(T width = 0) - { - bool carry = ((--m_counter) <= 0); - if (carry) - { - if (!width) - m_width = m_width_latch; - else - m_width = width; // reset width - m_counter = m_width; - m_cycle = 0; - } - else - m_cycle++; - - m_edge.tick(carry); - return carry; - } - - void set_width(T width) { m_width = width; } - void set_width_latch(T width) { m_width_latch = width; } - - // Accessors - bool current_edge() { return m_edge.m_current; } - bool rising_edge() { return m_edge.m_rising; } - bool falling_edge() { return m_edge.m_rising; } - T cycle() { return m_cycle; } - - struct edge_t - { - edge_t() - : m_current(InitEdge ^ 1) - , m_previous(InitEdge) - , m_rising(0) - , m_falling(0) - , m_changed(0) - { - set(InitEdge); - } - - void tick(bool toggle) - { - u8 current = m_current; - if (toggle) - current ^= 1; - set(current); - } - - void set(u8 edge) - { - edge &= 1; - m_rising = m_falling = m_changed = 0; - if (m_current != edge) - { - m_changed = 1; - if (m_current && (!edge)) - m_falling = 1; - else if ((!m_current) && edge) - m_rising = 1; - m_current = edge; - } - m_previous = m_current; - } - - void reset() - { - m_previous = InitEdge; - m_current = InitEdge ^ 1; - set(InitEdge); - } - - u8 m_current : 1; // current edge - u8 m_previous : 1; // previous edge - u8 m_rising : 1; // rising edge - u8 m_falling : 1; // falling edge - u8 m_changed : 1; // changed flag - }; - - edge_t m_edge; - T m_width = InitWidth; // clock pulse width - T m_width_latch = InitWidth; // clock pulse width latch - T m_counter = InitWidth; // clock counter - T m_cycle = 0; // clock cycle - }; -}; +#include +#include +#include "util.hpp" // ES5504/ES5505/ES5506 interface -using namespace es550x; class es550x_intf { public: @@ -158,7 +33,6 @@ public: }; // Shared functions for ES5504/ES5505/ES5506 -using namespace es550x; class es550x_shared_core { friend class es550x_intf; // es550x specific memory interface diff --git a/src/engine/platform/sound/es550x/es550x_alu.cpp b/src/engine/platform/sound/es550x/es550x_alu.cpp index 7e1ec05c..cf22517e 100644 --- a/src/engine/platform/sound/es550x/es550x_alu.cpp +++ b/src/engine/platform/sound/es550x/es550x_alu.cpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Ensoniq ES5504/ES5505/ES5506 Shared Accumulator emulation core diff --git a/src/engine/platform/sound/es550x/es550x_filter.cpp b/src/engine/platform/sound/es550x/es550x_filter.cpp index abf16b4d..45fd0571 100644 --- a/src/engine/platform/sound/es550x/es550x_filter.cpp +++ b/src/engine/platform/sound/es550x/es550x_filter.cpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Ensoniq ES5504/ES5505/ES5506 Shared Filter emulation core diff --git a/src/engine/platform/sound/es550x/util.hpp b/src/engine/platform/sound/es550x/util.hpp new file mode 100644 index 00000000..a66f4ca8 --- /dev/null +++ b/src/engine/platform/sound/es550x/util.hpp @@ -0,0 +1,139 @@ +/* + License: BSD-3-Clause + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details + + Copyright holder(s): cam900 + Various core utilities for vgsound_emu +*/ + +#ifndef _VGSOUND_EMU_CORE_UTIL_HPP +#define _VGSOUND_EMU_CORE_UTIL_HPP + +#pragma once + +#include +#include + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; +typedef signed char s8; +typedef signed short s16; +typedef signed int s32; + +// get bitfield, bitfield(input, position, len) +template T bitfield(T in, u8 pos, u8 len = 1) +{ + return (in >> pos) & (len ? (T(1 << len) - 1) : 1); +} + +// get sign extended value, sign_ext(input, len) +template T sign_ext(T in, u8 len) +{ + len = std::max(0, (8 * sizeof(T)) - len); + return T(T(in) << len) >> len; +} + +// std::clamp is only for C++17 or later; I use my own code +template T clamp(T in, T min, T max) +{ + return std::min(std::max(in, min), max); +} + +template +struct clock_pulse_t +{ + void reset(T init = InitWidth) + { + m_edge.reset(); + m_width = m_width_latch = m_counter = init; + m_cycle = 0; + } + + bool tick(T width = 0) + { + bool carry = ((--m_counter) <= 0); + if (carry) + { + if (!width) + m_width = m_width_latch; + else + m_width = width; // reset width + m_counter = m_width; + m_cycle = 0; + } + else + m_cycle++; + + m_edge.tick(carry); + return carry; + } + + void set_width(T width) { m_width = width; } + void set_width_latch(T width) { m_width_latch = width; } + + // Accessors + bool current_edge() { return m_edge.m_current; } + bool rising_edge() { return m_edge.m_rising; } + bool falling_edge() { return m_edge.m_rising; } + T cycle() { return m_cycle; } + + struct edge_t + { + edge_t() + : m_current(InitEdge ^ 1) + , m_previous(InitEdge) + , m_rising(0) + , m_falling(0) + , m_changed(0) + { + set(InitEdge); + } + + void tick(bool toggle) + { + u8 current = m_current; + if (toggle) + current ^= 1; + set(current); + } + + void set(u8 edge) + { + edge &= 1; + m_rising = m_falling = m_changed = 0; + if (m_current != edge) + { + m_changed = 1; + if (m_current && (!edge)) + m_falling = 1; + else if ((!m_current) && edge) + m_rising = 1; + m_current = edge; + } + m_previous = m_current; + } + + void reset() + { + m_previous = InitEdge; + m_current = InitEdge ^ 1; + set(InitEdge); + } + + u8 m_current : 1; // current edge + u8 m_previous : 1; // previous edge + u8 m_rising : 1; // rising edge + u8 m_falling : 1; // falling edge + u8 m_changed : 1; // changed flag + }; + + edge_t m_edge; + T m_width = InitWidth; // clock pulse width + T m_width_latch = InitWidth; // clock pulse width latch + T m_counter = InitWidth; // clock counter + T m_cycle = 0; // clock cycle +}; + +#endif diff --git a/src/engine/platform/sound/k005289/k005289.cpp b/src/engine/platform/sound/k005289/k005289.cpp index 4763b63f..6c716468 100644 --- a/src/engine/platform/sound/k005289/k005289.cpp +++ b/src/engine/platform/sound/k005289/k005289.cpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Konami K005289 emulation core diff --git a/src/engine/platform/sound/k005289/k005289.hpp b/src/engine/platform/sound/k005289/k005289.hpp index fe5d50ac..69c48eeb 100644 --- a/src/engine/platform/sound/k005289/k005289.hpp +++ b/src/engine/platform/sound/k005289/k005289.hpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Konami K005289 emulation core diff --git a/src/engine/platform/sound/n163/n163.cpp b/src/engine/platform/sound/n163/n163.cpp index e6801fc1..7ece05f6 100644 --- a/src/engine/platform/sound/n163/n163.cpp +++ b/src/engine/platform/sound/n163/n163.cpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Namco 163 Sound emulation core diff --git a/src/engine/platform/sound/n163/n163.hpp b/src/engine/platform/sound/n163/n163.hpp index aa059206..921d9cc6 100644 --- a/src/engine/platform/sound/n163/n163.hpp +++ b/src/engine/platform/sound/n163/n163.hpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Namco 163 Sound emulation core diff --git a/src/engine/platform/sound/oki/msm6295.cpp b/src/engine/platform/sound/oki/msm6295.cpp index 7a455e1b..4ae9541a 100644 --- a/src/engine/platform/sound/oki/msm6295.cpp +++ b/src/engine/platform/sound/oki/msm6295.cpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/blob/main/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 OKI MSM6295 emulation core diff --git a/src/engine/platform/sound/oki/msm6295.hpp b/src/engine/platform/sound/oki/msm6295.hpp index f5684a29..172c0194 100644 --- a/src/engine/platform/sound/oki/msm6295.hpp +++ b/src/engine/platform/sound/oki/msm6295.hpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/blob/main/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 OKI MSM6295 emulation core diff --git a/src/engine/platform/sound/oki/util.hpp b/src/engine/platform/sound/oki/util.hpp index 71e10cbe..fa7d3608 100644 --- a/src/engine/platform/sound/oki/util.hpp +++ b/src/engine/platform/sound/oki/util.hpp @@ -1,8 +1,8 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/blob/main/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details - Copyright holders: cam900 + Copyright holder(s): cam900 Various core utilities for vgsound_emu */ diff --git a/src/engine/platform/sound/oki/vox.hpp b/src/engine/platform/sound/oki/vox.hpp index b1fc6e23..b4ea7d09 100644 --- a/src/engine/platform/sound/oki/vox.hpp +++ b/src/engine/platform/sound/oki/vox.hpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/blob/main/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Dialogic ADPCM core diff --git a/src/engine/platform/sound/scc/scc.cpp b/src/engine/platform/sound/scc/scc.cpp index b9758fae..b045c637 100644 --- a/src/engine/platform/sound/scc/scc.cpp +++ b/src/engine/platform/sound/scc/scc.cpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Konami SCC emulation core diff --git a/src/engine/platform/sound/scc/scc.hpp b/src/engine/platform/sound/scc/scc.hpp index e696c403..e5b737be 100644 --- a/src/engine/platform/sound/scc/scc.hpp +++ b/src/engine/platform/sound/scc/scc.hpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Konami SCC emulation core diff --git a/src/engine/platform/sound/vrcvi/vrcvi.cpp b/src/engine/platform/sound/vrcvi/vrcvi.cpp index a6561db8..d0b49186 100644 --- a/src/engine/platform/sound/vrcvi/vrcvi.cpp +++ b/src/engine/platform/sound/vrcvi/vrcvi.cpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Konami VRC VI sound emulation core diff --git a/src/engine/platform/sound/vrcvi/vrcvi.hpp b/src/engine/platform/sound/vrcvi/vrcvi.hpp index d88ba7cf..cec160da 100644 --- a/src/engine/platform/sound/vrcvi/vrcvi.hpp +++ b/src/engine/platform/sound/vrcvi/vrcvi.hpp @@ -1,6 +1,6 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details Copyright holder(s): cam900 Konami VRC VI sound emulation core diff --git a/src/engine/platform/sound/x1_010/x1_010.cpp b/src/engine/platform/sound/x1_010/x1_010.cpp index 150928e6..b667008d 100644 --- a/src/engine/platform/sound/x1_010/x1_010.cpp +++ b/src/engine/platform/sound/x1_010/x1_010.cpp @@ -1,8 +1,8 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details - Copyright holders: cam900 + Copyright holder(s): cam900 Seta/Allumer X1-010 Emulation core the chip has 16 voices, all voices can be switchable to Wavetable or PCM sample playback mode. diff --git a/src/engine/platform/sound/x1_010/x1_010.hpp b/src/engine/platform/sound/x1_010/x1_010.hpp index f208611d..59e33e39 100644 --- a/src/engine/platform/sound/x1_010/x1_010.hpp +++ b/src/engine/platform/sound/x1_010/x1_010.hpp @@ -1,8 +1,8 @@ /* License: BSD-3-Clause - see https://github.com/cam900/vgsound_emu/LICENSE for more details + see https://github.com/cam900/vgsound_emu/blob/vgsound_emu_v1/LICENSE for more details - Copyright holders: cam900 + Copyright holder(s): cam900 Seta/Allumer X1-010 Emulation core See x1_010.cpp for more info. diff --git a/src/engine/platform/su.cpp b/src/engine/platform/su.cpp index b9e7f319..c294e179 100644 --- a/src/engine/platform/su.cpp +++ b/src/engine/platform/su.cpp @@ -213,7 +213,7 @@ void DivPlatformSoundUnit::tick(bool sysTick) { DivInstrument* ins=parent->getIns(chan[i].ins,DIV_INS_SU); DivSample* sample=parent->getSample(ins->amiga.getSample(chan[i].note)); if (sample!=NULL) { - unsigned int sampleEnd=sample->offSU+(s->isLoopable()?sample->loopEnd:sample->samples); + unsigned int sampleEnd=sample->offSU+(sample->isLoopable()?sample->loopEnd:sample->samples); unsigned int off=sample->offSU+chan[i].hasOffset; chan[i].hasOffset=0; if (sampleEnd>=getSampleMemCapacity(0)) sampleEnd=getSampleMemCapacity(0)-1; @@ -221,7 +221,7 @@ void DivPlatformSoundUnit::tick(bool sysTick) { chWrite(i,0x0b,off>>8); chWrite(i,0x0c,sampleEnd&0xff); chWrite(i,0x0d,sampleEnd>>8); - if (s->isLoopable()) { + if (sample->isLoopable()) { unsigned int sampleLoop=sample->offSU+sample->loopStart; if (sampleLoop>=getSampleMemCapacity(0)) sampleLoop=getSampleMemCapacity(0)-1; chWrite(i,0x0e,sampleLoop&0xff); diff --git a/src/gui/debug.cpp b/src/gui/debug.cpp index 269b4284..991fc7f7 100644 --- a/src/gui/debug.cpp +++ b/src/gui/debug.cpp @@ -344,7 +344,7 @@ void putDispatchChan(void* data, int chanNum, int type) { ImGui::Text(" - pitch2: %d",ch->pitch2); ImGui::Text("* note: %d",ch->note); ImGui::Text(" - next: %d",ch->nextNote); - ImGui::Text(" - prev: %d",ch->prevNote); + ImGui::Text(" - curr: %d",ch->currNote); ImGui::Text("- ins: %d",ch->ins); ImGui::Text("- wave: %d",ch->wave); ImGui::Text("- VolMacroMax: %d",ch->volMacroMax); diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 279d1c57..3bf6befb 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -2587,252 +2587,289 @@ void FurnaceGUI::drawInsEdit() { P(ImGui::Checkbox("Don't test/gate before new note",&ins->c64.noTest)); ImGui::EndTabItem(); } - if (ins->type==DIV_INS_AMIGA || ins->type==DIV_INS_ES5506) if (ImGui::BeginTabItem("Sample")) { - String sName; - if (ins->amiga.initSample<0 || ins->amiga.initSample>=e->song.sampleLen) { - sName="none selected"; - } else { - sName=e->song.sample[ins->amiga.initSample]->name; - } - if (ImGui::BeginCombo("Initial Sample",sName.c_str())) { - String id; - for (int i=0; isong.sampleLen; i++) { - id=fmt::sprintf("%d: %s",i,e->song.sample[i]->name); - if (ImGui::Selectable(id.c_str(),ins->amiga.initSample==i)) { PARAMETER - ins->amiga.initSample=i; + if (ins->type==DIV_INS_AMIGA || ins->type==DIV_INS_ES5506) { + if (ImGui::BeginTabItem("Sample")) { + String sName; + if (ins->amiga.initSample<0 || ins->amiga.initSample>=e->song.sampleLen) { + sName="none selected"; + } else { + sName=e->song.sample[ins->amiga.initSample]->name; + } + if (ImGui::BeginCombo("Initial Sample",sName.c_str())) { + String id; + for (int i=0; isong.sampleLen; i++) { + id=fmt::sprintf("%d: %s",i,e->song.sample[i]->name); + if (ImGui::Selectable(id.c_str(),ins->amiga.initSample==i)) { PARAMETER + ins->amiga.initSample=i; + } + } + ImGui::EndCombo(); + } + ImGui::BeginDisabled(ins->amiga.useWave); + P(ImGui::Checkbox("Reversed playback",&ins->amiga.reversed)); + ImGui::EndDisabled(); + // Wavetable + ImGui::BeginDisabled(ins->amiga.useNoteMap||ins->amiga.transWave.enable); + P(ImGui::Checkbox("Use wavetable (Amiga only)",&ins->amiga.useWave)); + if (ins->amiga.useWave) { + int len=ins->amiga.waveLen+1; + if (ImGui::InputInt("Width",&len,2,16)) { + if (len<2) len=2; + if (len>256) len=256; + ins->amiga.waveLen=(len&(~1))-1; + PARAMETER } } - ImGui::EndCombo(); - } - ImGui::BeginDisabled(ins->amiga.useWave); - P(ImGui::Checkbox("Reversed playback",&ins->amiga.reversed)); - ImGui::EndDisabled(); - // Wavetable - ImGui::BeginDisabled(ins->amiga.useNoteMap||ins->amiga.transWave.enable); - P(ImGui::Checkbox("Use wavetable (Amiga only)",&ins->amiga.useWave)); - if (ins->amiga.useWave) { - int len=ins->amiga.waveLen+1; - if (ImGui::InputInt("Width",&len,2,16)) { - if (len<2) len=2; - if (len>256) len=256; - ins->amiga.waveLen=(len&(~1))-1; - PARAMETER - } - } - ImGui::EndDisabled(); - // Note map - ImGui::BeginDisabled(ins->amiga.useWave||ins->amiga.transWave.enable); - P(ImGui::Checkbox("Use sample map (does not work yet!)",&ins->amiga.useNoteMap)); - if (ins->amiga.useNoteMap) { - if (ImGui::BeginTable("NoteMap",4,ImGuiTableFlags_ScrollY|ImGuiTableFlags_Borders|ImGuiTableFlags_SizingStretchSame)) { - ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed); - ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch); - ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch); - ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthStretch); + ImGui::EndDisabled(); + // Note map + ImGui::BeginDisabled(ins->amiga.useWave||ins->amiga.transWave.enable); + P(ImGui::Checkbox("Use sample map (does not work yet!)",&ins->amiga.useNoteMap)); + if (ins->amiga.useNoteMap) { + if (ImGui::BeginTable("NoteMap",4,ImGuiTableFlags_ScrollY|ImGuiTableFlags_Borders|ImGuiTableFlags_SizingStretchSame)) { + ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch); + ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch); + ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthStretch); - ImGui::TableSetupScrollFreeze(0,1); + ImGui::TableSetupScrollFreeze(0,1); - ImGui::TableNextRow(ImGuiTableRowFlags_Headers); - ImGui::TableNextColumn(); - ImGui::TableNextColumn(); - ImGui::Text("Sample"); - ImGui::TableNextColumn(); - ImGui::Text("Frequency"); - ImGui::TableNextColumn(); - ImGui::Text("Reversed"); - for (int i=0; i<120; i++) { - ImGui::TableNextRow(); - ImGui::PushID(fmt::sprintf("NM_%d",i).c_str()); + ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextColumn(); - ImGui::Text("%s",noteNames[60+i]); ImGui::TableNextColumn(); - if (ins->amiga.noteMap[i].ind<0 || ins->amiga.noteMap[i].ind>=e->song.sampleLen) { - sName="-- empty --"; - ins->amiga.noteMap[i].ind=-1; - } else { - sName=e->song.sample[ins->amiga.noteMap[i].ind]->name; - } - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - if (ImGui::BeginCombo(fmt::sprintf("##SampleMap_Index_%d",i).c_str(),sName.c_str())) { - String id; - if (ImGui::Selectable("-- empty --",ins->amiga.noteMap[i].ind==-1)) { PARAMETER + ImGui::Text("Sample"); + ImGui::TableNextColumn(); + ImGui::Text("Frequency"); + ImGui::TableNextColumn(); + ImGui::Text("Reversed"); + for (int i=0; i<120; i++) { + ImGui::TableNextRow(); + ImGui::PushID(fmt::sprintf("NM_%d",i).c_str()); + ImGui::TableNextColumn(); + ImGui::Text("%s",noteNames[60+i]); + ImGui::TableNextColumn(); + if (ins->amiga.noteMap[i].ind<0 || ins->amiga.noteMap[i].ind>=e->song.sampleLen) { + sName="-- empty --"; ins->amiga.noteMap[i].ind=-1; + } else { + sName=e->song.sample[ins->amiga.noteMap[i].ind]->name; } - for (int j=0; jsong.sampleLen; j++) { - id=fmt::sprintf("%d: %s",j,e->song.sample[j]->name); - if (ImGui::Selectable(id.c_str(),ins->amiga.noteMap[i].ind==j)) { PARAMETER - ins->amiga.noteMap[i].ind=j; - if (ins->amiga.noteMap[i].freq<=0) ins->amiga.noteMap[i].freq=(int)((double)e->song.sample[j]->centerRate*pow(2.0,((double)i-48.0)/12.0)); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::BeginCombo(fmt::sprintf("##SampleMap_Index_%d",i).c_str(),sName.c_str())) { + String id; + if (ImGui::Selectable("-- empty --",ins->amiga.noteMap[i].ind==-1)) { PARAMETER + ins->amiga.noteMap[i].ind=-1; + } + for (int j=0; jsong.sampleLen; j++) { + id=fmt::sprintf("%d: %s",j,e->song.sample[j]->name); + if (ImGui::Selectable(id.c_str(),ins->amiga.noteMap[i].ind==j)) { PARAMETER + ins->amiga.noteMap[i].ind=j; + if (ins->amiga.noteMap[i].freq<=0) ins->amiga.noteMap[i].freq=(int)((double)e->song.sample[j]->centerRate*pow(2.0,((double)i-48.0)/12.0)); + } + } + ImGui::EndCombo(); + } + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::InputInt(fmt::sprintf("##SampleMap_Freq_%d",i).c_str(),&ins->amiga.noteMap[i].freq,50,500)) { PARAMETER + if (ins->amiga.noteMap[i].freq<0) ins->amiga.noteMap[i].freq=0; + if (ins->amiga.noteMap[i].freq>262144) ins->amiga.noteMap[i].freq=262144; + } + ImGui::TableNextColumn(); + if (ImGui::RadioButton(fmt::sprintf("Disable##SampleMap_Reversed_Disable_%d",i).c_str(),ins->amiga.noteMap[i].reversed==0)) { MARK_MODIFIED + ins->amiga.noteMap[i].reversed=0; + } + if (ImGui::RadioButton(fmt::sprintf("Enable##SampleMap_Reversed_Enable_%d",i).c_str(),ins->amiga.noteMap[i].reversed==1)) { MARK_MODIFIED + ins->amiga.noteMap[i].reversed=1; + } + if (ImGui::RadioButton(fmt::sprintf("Use instrument setting##SampleMap_Reversed_Default_%d",i).c_str(),ins->amiga.noteMap[i].reversed==2)) { MARK_MODIFIED + ins->amiga.noteMap[i].reversed=2; + } + ImGui::PopID(); + } + ImGui::EndTable(); + } + } + ImGui::EndDisabled(); + // Transwave + ImGui::BeginDisabled(ins->amiga.useNoteMap||ins->amiga.useWave||ins->amiga.useNoteMap); + P(ImGui::Checkbox("Use Transwave##UseTransWave",&ins->amiga.transWave.enable)); + if (ins->amiga.transWave.enable) { + int size=ins->amiga.transWaveMap.size(); + if (ImGui::InputInt("Transwave Map Size##TransWaveSize",&size,1,16)) { PARAMETER + if (size<=ins->amiga.transWave.ind) size=ins->amiga.transWave.ind+1; + if (size<1) size=1; + if (size>256) size=256; + if (ins->amiga.transWaveMap.size()!=(size_t)(size)) { + ins->amiga.transWaveMap.resize(size,DivInstrumentAmiga::TransWaveMap()); + if (ins->amiga.transWaveMap.capacity()>(size_t)(size)) { + ins->amiga.transWaveMap.shrink_to_fit(); + } + } + } + if (ImGui::InputInt("Initial Transwave Index##TransWaveInit",&ins->amiga.transWave.ind,1,16)) { PARAMETER + if (ins->amiga.transWave.ind<1) ins->amiga.transWave.ind=0; + if (ins->amiga.transWave.ind>=(int)(ins->amiga.transWaveMap.size())) ins->amiga.transWave.ind=ins->amiga.transWaveMap.size()-1; + if (ins->amiga.transWave.sliceEnable) { + DivInstrumentAmiga::TransWaveMap ind=ins->amiga.transWaveMap[ins->amiga.transWave.ind]; + if (ind.ind>=0 && ind.ind<(short)(e->song.sampleLen)) { + DivSample* s=e->song.sample[ind.ind]; + ins->amiga.transWave.updateSize(s->samples,ind.loopStart,ind.loopEnd); + ins->amiga.transWave.slicePos((double)(ins->amiga.transWave.slice)/4095.0); + } + } + } + if (ImGui::Checkbox("Use Transwave Slice##UseTransWaveSlice",&ins->amiga.transWave.sliceEnable)) { PARAMETER + if (ins->amiga.transWave.sliceEnable) { + ins->amiga.transWave.slicePos((double)(ins->amiga.transWave.slice)/4095.0); + if (ins->amiga.transWave.sliceEnable) { + DivInstrumentAmiga::TransWaveMap ind=ins->amiga.transWaveMap[ins->amiga.transWave.ind]; + if (ind.ind>=0 && ind.ind<(short)(e->song.sampleLen)) { + DivSample* s=e->song.sample[ind.ind]; + ins->amiga.transWave.updateSize(s->samples,ind.loopStart,ind.loopEnd); + ins->amiga.transWave.slicePos((double)(ins->amiga.transWave.slice)/4095.0); } } - ImGui::EndCombo(); - } - ImGui::TableNextColumn(); - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - if (ImGui::InputInt(fmt::sprintf("##SampleMap_Freq_%d",i).c_str(),&ins->amiga.noteMap[i].freq,50,500)) { PARAMETER - if (ins->amiga.noteMap[i].freq<0) ins->amiga.noteMap[i].freq=0; - if (ins->amiga.noteMap[i].freq>262144) ins->amiga.noteMap[i].freq=262144; - } - ImGui::TableNextColumn(); - if (ImGui::RadioButton(fmt::sprintf("Disable##SampleMap_Reversed_Disable_%d",i).c_str(),ins->amiga.noteMap[i].reversed==0)) { MARK_MODIFIED - ins->amiga.noteMap[i].reversed=0; - } - if (ImGui::RadioButton(fmt::sprintf("Enable##SampleMap_Reversed_Enable_%d",i).c_str(),ins->amiga.noteMap[i].reversed==1)) { MARK_MODIFIED - ins->amiga.noteMap[i].reversed=1; - } - if (ImGui::RadioButton(fmt::sprintf("Use instrument setting##SampleMap_Reversed_Default_%d",i).c_str(),ins->amiga.noteMap[i].reversed==2)) { MARK_MODIFIED - ins->amiga.noteMap[i].reversed=2; - } - ImGui::PopID(); - } - ImGui::EndTable(); - } - } - ImGui::EndDisabled(); - // Transwave - ImGui::BeginDisabled(ins->amiga.useNoteMap||ins->amiga.useWave||ins->amiga.useNoteMap); - P(ImGui::Checkbox("Use Transwave##UseTransWave",&ins->amiga.transWave.enable)); - if (ins->amiga.transWave.enable) { - int size=ins->amiga.transWaveMap.size(); - if (ImGui::InputInt("Transwave Map Size##TransWaveSize",&size,1,16)) { PARAMETER - if (size<=ins->amiga.transWave.ind) size=ins->amiga.transWave.ind+1; - if (size<1) size=1; - if (size>256) size=256; - if (ins->amiga.transWaveMap.size()!=(size_t)(size)) { - ins->amiga.transWaveMap.resize(size,DivInstrumentAmiga::TransWaveMap()); - if (ins->amiga.transWaveMap.capacity()>(size_t)(size)) { - ins->amiga.transWaveMap.shrink_to_fit(); } } - } - if (ImGui::InputInt("Initial Transwave Index##TransWaveInit",&ins->amiga.transWave.ind,1,16)) { PARAMETER - if (ins->amiga.transWave.ind<1) ins->amiga.transWave.ind=0; - if (ins->amiga.transWave.ind>=(int)(ins->amiga.transWaveMap.size())) ins->amiga.transWave.ind=ins->amiga.transWaveMap.size()-1; - } - P(ImGui::Checkbox("Use Transwave Slice##UseTransWaveSlice",&ins->amiga.transWave.sliceEnable)); - DivInstrumentAmiga::TransWaveMap ind=ins->amiga.transWaveMap[ins->amiga.transWave.ind]; - if (ins->amiga.transWave.sliceEnable && (ind.ind>=0 && ind.indsong.sampleLen)) { - double sliceInit=(double)(ins->amiga.transWave.slice)/4095.0; - double slicePos=ins->amiga.transWave.slicePos(sliceInit); - double sliceStart=ins->amiga.transWave.sliceStart; - double sliceEnd=ins->amiga.transWave.sliceEnd; - P(CWSliderScalar("Initial Transwave Slice##TransWaveSliceInit",ImGuiDataType_U16,&ins->amiga.transWave.slice,&_ZERO,&_FOUR_THOUSAND_NINETY_FIVE,fmt::sprintf("%d: %.6f - %.6f",ins->amiga.transWave.slice,sliceStart,sliceEnd).c_str())); rightClickable - ImGui::Text("Position: %.6f", slicePos); - } - if (ImGui::BeginTable("TransWaveMap",6,ImGuiTableFlags_ScrollY|ImGuiTableFlags_Borders|ImGuiTableFlags_SizingStretchSame)) { - ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed); // Number - ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch); // Sample index - ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch); // Loop start - ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthStretch); // Loop end - ImGui::TableSetupColumn("c4",ImGuiTableColumnFlags_WidthStretch); // Loop mode - ImGui::TableSetupColumn("c5",ImGuiTableColumnFlags_WidthStretch); // Reversed + DivInstrumentAmiga::TransWaveMap ind=ins->amiga.transWaveMap[ins->amiga.transWave.ind]; + if (ins->amiga.transWave.sliceEnable && (ind.ind>=0 && ind.indsong.sampleLen)) { + ins->amiga.transWave.slicePos((double)(ins->amiga.transWave.slice)/4095.0); + double sliceStart=ins->amiga.transWave.sliceStart; + double sliceEnd=ins->amiga.transWave.sliceEnd; + if (CWSliderScalar("Initial Transwave Slice##TransWaveSliceInit",ImGuiDataType_U16,&ins->amiga.transWave.slice,&_ZERO,&_FOUR_THOUSAND_NINETY_FIVE,fmt::sprintf("%d: %.6f - %.6f",ins->amiga.transWave.slice,sliceStart,sliceEnd).c_str())) { PARAMETER + ins->amiga.transWave.slicePos((double)(ins->amiga.transWave.slice)/4095.0); + } rightClickable + } + if (ImGui::BeginTable("TransWaveMap",6,ImGuiTableFlags_ScrollY|ImGuiTableFlags_Borders|ImGuiTableFlags_SizingStretchSame)) { + ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed); // Number + ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch); // Sample index + ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch); // Loop start + ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthStretch); // Loop end + ImGui::TableSetupColumn("c4",ImGuiTableColumnFlags_WidthStretch); // Loop mode + ImGui::TableSetupColumn("c5",ImGuiTableColumnFlags_WidthStretch); // Reversed - ImGui::TableSetupScrollFreeze(0,1); + ImGui::TableSetupScrollFreeze(0,1); - ImGui::TableNextRow(ImGuiTableRowFlags_Headers); - ImGui::TableNextColumn(); - ImGui::TableNextColumn(); - ImGui::Text("Sample"); - ImGui::TableNextColumn(); - ImGui::Text("Loop Start"); - ImGui::TableNextColumn(); - ImGui::Text("Loop End"); - ImGui::TableNextColumn(); - ImGui::Text("Loop Mode"); - ImGui::TableNextColumn(); - ImGui::Text("Reversed"); - for (size_t i=0; iamiga.transWaveMap.size(); i++) { - DivInstrumentAmiga::TransWaveMap& transWaveMap=ins->amiga.transWaveMap[i]; - ImGui::TableNextRow(); - ImGui::PushID(fmt::sprintf("TransWaveMap_%d",i).c_str()); + ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextColumn(); - ImGui::Text("%d",(int)(i)); ImGui::TableNextColumn(); - if (transWaveMap.ind<0 || transWaveMap.ind>=e->song.sampleLen) { - sName="-- empty --"; - transWaveMap.ind=-1; - } else { - sName=e->song.sample[transWaveMap.ind]->name; - } - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - if (ImGui::BeginCombo(fmt::sprintf("##TransWaveMap_Index_%d",i).c_str(),sName.c_str())) { - String id; - if (ImGui::Selectable("-- empty --",transWaveMap.ind==-1)) { PARAMETER + ImGui::Text("Sample"); + ImGui::TableNextColumn(); + ImGui::Text("Loop Start"); + ImGui::TableNextColumn(); + ImGui::Text("Loop End"); + ImGui::TableNextColumn(); + ImGui::Text("Loop Mode"); + ImGui::TableNextColumn(); + ImGui::Text("Reversed"); + for (size_t i=0; iamiga.transWaveMap.size(); i++) { + DivInstrumentAmiga::TransWaveMap& transWaveMap=ins->amiga.transWaveMap[i]; + ImGui::TableNextRow(); + ImGui::PushID(fmt::sprintf("TransWaveMap_%d",i).c_str()); + ImGui::TableNextColumn(); + ImGui::Text("%d",(int)(i)); + ImGui::TableNextColumn(); + if (transWaveMap.ind<0 || transWaveMap.ind>=e->song.sampleLen) { + sName="-- empty --"; transWaveMap.ind=-1; + } else { + sName=e->song.sample[transWaveMap.ind]->name; } - for (int j=0; jsong.sampleLen; j++) { - DivSample* s=e->song.sample[j]; - id=fmt::sprintf("%d: %s",j,s->name); - if (ImGui::Selectable(id.c_str(),transWaveMap.ind==j)) { PARAMETER - transWaveMap.ind=j; - if (transWaveMap.loopStart<0 || transWaveMap.loopStart>(int)(s->samples)) { - transWaveMap.loopStart=s->loopStart; - } - if (transWaveMap.loopEnd<0 || transWaveMap.loopEnd>(int)(s->samples)) { - transWaveMap.loopEnd=s->loopEnd; + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::BeginCombo(fmt::sprintf("##TransWaveMap_Index_%d",i).c_str(),sName.c_str())) { + String id; + if (ImGui::Selectable("-- empty --",transWaveMap.ind==-1)) { PARAMETER + transWaveMap.ind=-1; + } + for (int j=0; jsong.sampleLen; j++) { + DivSample* s=e->song.sample[j]; + id=fmt::sprintf("%d: %s",j,s->name); + if (ImGui::Selectable(id.c_str(),transWaveMap.ind==j)) { PARAMETER + transWaveMap.ind=j; + if (transWaveMap.loopStart<0 || transWaveMap.loopStart>(int)(s->samples)) { + transWaveMap.loopStart=s->loopStart; + } + if (transWaveMap.loopEnd<0 || transWaveMap.loopEnd>(int)(s->samples)) { + transWaveMap.loopEnd=s->loopEnd; + } + transWaveMap.updateSize(s->samples,transWaveMap.loopStart,transWaveMap.loopEnd); + if (ins->amiga.transWave.sliceEnable && i==ins->amiga.transWave.ind) { + ins->amiga.transWave.updateSize(s->samples,transWaveMap.loopStart,transWaveMap.loopEnd); + ins->amiga.transWave.slicePos((double)(ins->amiga.transWave.slice)/4095.0); + } } + } + ImGui::EndCombo(); + } + ImGui::BeginDisabled(transWaveMap.ind<0 || transWaveMap.ind>=e->song.sampleLen); + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::InputInt(fmt::sprintf("##TransWaveMap_LoopStart_%d",i).c_str(),&transWaveMap.loopStart,256,4096)) { PARAMETER + if (transWaveMap.ind>=0 && transWaveMap.indsong.sampleLen) { + DivSample* s=e->song.sample[transWaveMap.ind]; + if (transWaveMap.loopStart<0) transWaveMap.loopStart=0; + if (transWaveMap.loopStart>transWaveMap.loopEnd) transWaveMap.loopStart=transWaveMap.loopEnd; transWaveMap.updateSize(s->samples,transWaveMap.loopStart,transWaveMap.loopEnd); + if (ins->amiga.transWave.sliceEnable && i==ins->amiga.transWave.ind) { + ins->amiga.transWave.updateSize(s->samples,transWaveMap.loopStart,transWaveMap.loopEnd); + ins->amiga.transWave.slicePos((double)(ins->amiga.transWave.slice)/4095.0); + } } } - ImGui::EndCombo(); - } - ImGui::BeginDisabled(transWaveMap.ind<0 || transWaveMap.ind>=e->song.sampleLen); - ImGui::TableNextColumn(); - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - if (ImGui::InputInt(fmt::sprintf("##TransWaveMap_LoopStart_%d",i).c_str(),&transWaveMap.loopStart,256,4096)) { PARAMETER - if (transWaveMap.ind>=0 && transWaveMap.indsong.sampleLen) { - DivSample* s=e->song.sample[transWaveMap.ind]; - if (transWaveMap.loopStart<0) transWaveMap.loopStart=0; - if (transWaveMap.loopStart>transWaveMap.loopEnd) transWaveMap.loopStart=transWaveMap.loopEnd; - transWaveMap.updateSize(s->samples,transWaveMap.loopStart,transWaveMap.loopEnd); + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::InputInt(fmt::sprintf("##TransWaveMap_LoopEnd_%d",i).c_str(),&transWaveMap.loopEnd,256,4096)) { PARAMETER + if (transWaveMap.ind>=0 && transWaveMap.indsong.sampleLen) { + DivSample* s=e->song.sample[transWaveMap.ind]; + if (transWaveMap.loopEnd(int)(s->samples)) transWaveMap.loopEnd=s->samples; + transWaveMap.updateSize(s->samples,transWaveMap.loopStart,transWaveMap.loopEnd); + if (ins->amiga.transWave.sliceEnable) { + ins->amiga.transWave.updateSize(s->samples,transWaveMap.loopStart,transWaveMap.loopEnd); + ins->amiga.transWave.slicePos((double)(ins->amiga.transWave.slice)/4095.0); + } + } } - } - ImGui::TableNextColumn(); - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - if (ImGui::InputInt(fmt::sprintf("##TransWaveMap_LoopEnd_%d",i).c_str(),&transWaveMap.loopEnd,256,4096)) { PARAMETER - if (transWaveMap.ind>=0 && transWaveMap.indsong.sampleLen) { - DivSample* s=e->song.sample[transWaveMap.ind]; - if (transWaveMap.loopEnd(int)(s->samples)) transWaveMap.loopEnd=s->samples; - transWaveMap.updateSize(s->samples,transWaveMap.loopStart,transWaveMap.loopEnd); + ImGui::TableNextColumn(); + if (ImGui::RadioButton(fmt::sprintf("Forward##TransWaveMap_LoopMode_Forward_%d",i).c_str(),transWaveMap.loopMode==DIV_SAMPLE_LOOPMODE_FORWARD)) { MARK_MODIFIED + transWaveMap.loopMode=DIV_SAMPLE_LOOPMODE_FORWARD; } + if (ImGui::RadioButton(fmt::sprintf("Backward##TransWaveMap_LoopMode_Backward_%d",i).c_str(),transWaveMap.loopMode==DIV_SAMPLE_LOOPMODE_BACKWARD)) { MARK_MODIFIED + transWaveMap.loopMode=DIV_SAMPLE_LOOPMODE_BACKWARD; + } + if (ImGui::RadioButton(fmt::sprintf("Pingpong##TransWaveMap_LoopMode_Pingpong_%d",i).c_str(),transWaveMap.loopMode==DIV_SAMPLE_LOOPMODE_PINGPONG)) { MARK_MODIFIED + transWaveMap.loopMode=DIV_SAMPLE_LOOPMODE_PINGPONG; + } + if (ImGui::RadioButton(fmt::sprintf("Use sample setting##TransWaveMap_LoopMode_Default_%d",i).c_str(),transWaveMap.loopMode==DIV_SAMPLE_LOOPMODE_ONESHOT)) { MARK_MODIFIED + transWaveMap.loopMode=DIV_SAMPLE_LOOPMODE_ONESHOT; + } + ImGui::TableNextColumn(); + if (ImGui::RadioButton(fmt::sprintf("Disable##TransWaveMap_Reversed_Disable_%d",i).c_str(),transWaveMap.reversed==0)) { MARK_MODIFIED + transWaveMap.reversed=0; + } + if (ImGui::RadioButton(fmt::sprintf("Enable##TransWaveMap_Reversed_Enable_%d",i).c_str(),transWaveMap.reversed==1)) { MARK_MODIFIED + transWaveMap.reversed=1; + } + if (ImGui::RadioButton(fmt::sprintf("Use instrument setting##TransWaveMap_Reversed_Default_%d",i).c_str(),transWaveMap.reversed==2)) { MARK_MODIFIED + transWaveMap.reversed=2; + } + ImGui::EndDisabled(); + ImGui::PopID(); } - ImGui::TableNextColumn(); - if (ImGui::RadioButton(fmt::sprintf("Forward##TransWaveMap_LoopMode_Forward_%d",i).c_str(),transWaveMap.loopMode==DIV_SAMPLE_LOOPMODE_FORWARD)) { MARK_MODIFIED - transWaveMap.loopMode=DIV_SAMPLE_LOOPMODE_FORWARD; - } - if (ImGui::RadioButton(fmt::sprintf("Backward##TransWaveMap_LoopMode_Backward_%d",i).c_str(),transWaveMap.loopMode==DIV_SAMPLE_LOOPMODE_BACKWARD)) { MARK_MODIFIED - transWaveMap.loopMode=DIV_SAMPLE_LOOPMODE_BACKWARD; - } - if (ImGui::RadioButton(fmt::sprintf("Pingpong##TransWaveMap_LoopMode_Pingpong_%d",i).c_str(),transWaveMap.loopMode==DIV_SAMPLE_LOOPMODE_PINGPONG)) { MARK_MODIFIED - transWaveMap.loopMode=DIV_SAMPLE_LOOPMODE_PINGPONG; - } - if (ImGui::RadioButton(fmt::sprintf("Use sample setting##TransWaveMap_LoopMode_Default_%d",i).c_str(),transWaveMap.loopMode==DIV_SAMPLE_LOOPMODE_ONESHOT)) { MARK_MODIFIED - transWaveMap.loopMode=DIV_SAMPLE_LOOPMODE_ONESHOT; - } - ImGui::TableNextColumn(); - if (ImGui::RadioButton(fmt::sprintf("Disable##TransWaveMap_Reversed_Disable_%d",i).c_str(),transWaveMap.reversed==0)) { MARK_MODIFIED - transWaveMap.reversed=0; - } - if (ImGui::RadioButton(fmt::sprintf("Enable##TransWaveMap_Reversed_Enable_%d",i).c_str(),transWaveMap.reversed==1)) { MARK_MODIFIED - transWaveMap.reversed=1; - } - if (ImGui::RadioButton(fmt::sprintf("Use instrument setting##TransWaveMap_Reversed_Default_%d",i).c_str(),transWaveMap.reversed==2)) { MARK_MODIFIED - transWaveMap.reversed=2; - } - ImGui::EndDisabled(); - ImGui::PopID(); + ImGui::EndTable(); } - ImGui::EndTable(); } + ImGui::EndDisabled(); + ImGui::EndTabItem(); + } + if (ins->amiga.transWave.enable) { if (ImGui::BeginTabItem("Transwave Macros")) { macroList.push_back(FurnaceGUIMacroDesc("Transwave control",&ins->std.fbMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,false,NULL,NULL,true,transwaveControlModes)); macroList.push_back(FurnaceGUIMacroDesc("Transwave slice",&ins->std.fmsMacro,0,4095,160,uiColors[GUI_COLOR_MACRO_OTHER])); + drawMacros(macroList); ImGui::EndTabItem(); } } - ImGui::EndDisabled(); - ImGui::EndTabItem(); } if (ins->type==DIV_INS_N163) if (ImGui::BeginTabItem("Namco 163")) { if (ImGui::InputInt("Waveform##WAVE",&ins->n163.wave,1,10)) { PARAMETER