Fix dead link, Frequency, Instrument editor related issue

This commit is contained in:
cam900 2022-05-31 13:48:35 +09:00
parent a3bca9efa7
commit 3b411cd14f
30 changed files with 432 additions and 384 deletions

View File

@ -296,7 +296,7 @@ void DivPlatformES5506::e_pin(bool state)
DivSample* s=parent->getSample(sample); DivSample* s=parent->getSample(sample);
// get frequency offset // get frequency offset
double off=1.0; double off=1.0;
double center=s->centerRate; double center=(double)s->centerRate;
if (center<1) { if (center<1) {
off=1.0; off=1.0;
} else { } else {
@ -710,7 +710,7 @@ void DivPlatformES5506::tick(bool sysTick) {
DivSample* s=parent->getSample(sample); DivSample* s=parent->getSample(sample);
// get frequency offset // get frequency offset
double off=1.0; double off=1.0;
double center=s->centerRate; double center=(double)s->centerRate;
if (center<1) { if (center<1) {
off=1.0; off=1.0;
} else { } else {
@ -884,33 +884,30 @@ void DivPlatformES5506::tick(bool sysTick) {
if (chan[i].noteChanged.offs) { if (chan[i].noteChanged.offs) {
if (chan[i].pcm.freqOffs!=chan[i].pcm.nextFreqOffs) { if (chan[i].pcm.freqOffs!=chan[i].pcm.nextFreqOffs) {
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) { if (chan[i].nextFreq!=nextFreq) {
chan[i].nextFreq=nextFreq; chan[i].nextFreq=nextFreq;
chan[i].noteChanged.freq=1; chan[i].noteChanged.freq=1;
} }
} }
chan[i].noteChanged.offs=0;
} }
if (chan[i].noteChanged.note) { if (chan[i].noteChanged.note) {
if (chan[i].prevNote!=chan[i].nextNote) { if (chan[i].currNote!=chan[i].nextNote) {
chan[i].prevNote=chan[i].nextNote; chan[i].currNote=chan[i].nextNote;
const int nextFreq=NOTE_ES5506(i,chan[i].nextNote); const int nextFreq=NOTE_ES5506(i,chan[i].nextNote);
if (chan[i].nextFreq!=nextFreq) { if (chan[i].nextFreq!=nextFreq) {
chan[i].nextFreq=nextFreq; chan[i].nextFreq=nextFreq;
chan[i].noteChanged.freq=1; chan[i].noteChanged.freq=1;
} }
} }
chan[i].noteChanged.note=0;
} }
if (chan[i].noteChanged.freq) { if (chan[i].noteChanged.freq) {
if (chan[i].baseFreq!=chan[i].nextFreq) { if (chan[i].baseFreq!=chan[i].nextFreq) {
chan[i].baseFreq=chan[i].nextFreq; chan[i].baseFreq=chan[i].nextFreq;
chan[i].freqChanged=true; 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) { 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); 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); DivSample* s=parent->getSample(sample);
// get frequency offset // get frequency offset
double off=1.0; double off=1.0;
double center=s->centerRate; double center=(double)s->centerRate;
if (center<1) { if (center<1) {
off=1.0; off=1.0;
} else { } else {
@ -1087,6 +1084,7 @@ int DivPlatformES5506::dispatch(DivCommand c) {
if (c.value!=DIV_NOTE_NULL) { if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].note=c.value; chan[c.chan].note=c.value;
chan[c.chan].nextNote=chan[c.chan].note; 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].freqChanged=true;
chan[c.chan].noteChanged.changed=0xff; chan[c.chan].noteChanged.changed=0xff;
chan[c.chan].volChanged.changed=0xff; chan[c.chan].volChanged.changed=0xff;

View File

@ -62,7 +62,7 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf {
loopEnd(0), loopEnd(0),
loopMode(DIV_SAMPLE_LOOPMODE_ONESHOT) {} loopMode(DIV_SAMPLE_LOOPMODE_ONESHOT) {}
} pcm; } 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; unsigned int volMacroMax, panMacroMax;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave, isReverseLoop, isTranswave, transwaveIRQ; bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave, isReverseLoop, isTranswave, transwaveIRQ;
unsigned int cr; unsigned int cr;
@ -173,7 +173,7 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf {
pitch2(0), pitch2(0),
note(0), note(0),
nextNote(0), nextNote(0),
prevNote(0), currNote(0),
ins(-1), ins(-1),
wave(-1), wave(-1),
volMacroMax(0xffff), volMacroMax(0xffff),

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Ensoniq ES5504 emulation core Ensoniq ES5504 emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Ensoniq ES5504 emulation core Ensoniq ES5504 emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Ensoniq ES5505 emulation core Ensoniq ES5505 emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Ensoniq ES5504 emulation core Ensoniq ES5504 emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Ensoniq ES5506 emulation core Ensoniq ES5506 emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Ensoniq ES5504 emulation core Ensoniq ES5504 emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Ensoniq ES5504/ES5505/ES5506 emulation core Ensoniq ES5504/ES5505/ES5506 emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Ensoniq ES5504/ES5505/ES5506 emulation core Ensoniq ES5504/ES5505/ES5506 emulation core
@ -8,141 +8,16 @@
See es550x.cpp for more info See es550x.cpp for more info
*/ */
#include <algorithm>
#include <memory>
#ifndef _VGSOUND_EMU_ES550X_HPP #ifndef _VGSOUND_EMU_ES550X_HPP
#define _VGSOUND_EMU_ES550X_HPP #define _VGSOUND_EMU_ES550X_HPP
#pragma once #pragma once
namespace es550x #include <algorithm>
{ #include <memory>
typedef unsigned char u8; #include "util.hpp"
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<typename T> T bitfield(T in, u8 pos, u8 len = 1)
{
return (in >> pos) & (len ? (T(1 << len) - 1) : 1);
}
// get sign extended value, sign_ext<type>(input, len)
template<typename T> T sign_ext(T in, u8 len)
{
len = std::max<u8>(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<typename T> T clamp(T in, T min, T max)
{
return std::min(std::max(in, min), max);
}
template<typename T, T InitWidth, u8 InitEdge = 0>
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
};
};
// ES5504/ES5505/ES5506 interface // ES5504/ES5505/ES5506 interface
using namespace es550x;
class es550x_intf class es550x_intf
{ {
public: public:
@ -158,7 +33,6 @@ public:
}; };
// Shared functions for ES5504/ES5505/ES5506 // Shared functions for ES5504/ES5505/ES5506
using namespace es550x;
class es550x_shared_core class es550x_shared_core
{ {
friend class es550x_intf; // es550x specific memory interface friend class es550x_intf; // es550x specific memory interface

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Ensoniq ES5504/ES5505/ES5506 Shared Accumulator emulation core Ensoniq ES5504/ES5505/ES5506 Shared Accumulator emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Ensoniq ES5504/ES5505/ES5506 Shared Filter emulation core Ensoniq ES5504/ES5505/ES5506 Shared Filter emulation core

View File

@ -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 <algorithm>
#include <memory>
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<typename T> T bitfield(T in, u8 pos, u8 len = 1)
{
return (in >> pos) & (len ? (T(1 << len) - 1) : 1);
}
// get sign extended value, sign_ext<type>(input, len)
template<typename T> T sign_ext(T in, u8 len)
{
len = std::max<u8>(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<typename T> T clamp(T in, T min, T max)
{
return std::min(std::max(in, min), max);
}
template<typename T, T InitWidth, u8 InitEdge = 0>
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

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Konami K005289 emulation core Konami K005289 emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Konami K005289 emulation core Konami K005289 emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Namco 163 Sound emulation core Namco 163 Sound emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Namco 163 Sound emulation core Namco 163 Sound emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
OKI MSM6295 emulation core OKI MSM6295 emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
OKI MSM6295 emulation core OKI MSM6295 emulation core

View File

@ -1,8 +1,8 @@
/* /*
License: BSD-3-Clause 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 Various core utilities for vgsound_emu
*/ */

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Dialogic ADPCM core Dialogic ADPCM core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Konami SCC emulation core Konami SCC emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Konami SCC emulation core Konami SCC emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Konami VRC VI sound emulation core Konami VRC VI sound emulation core

View File

@ -1,6 +1,6 @@
/* /*
License: BSD-3-Clause 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 Copyright holder(s): cam900
Konami VRC VI sound emulation core Konami VRC VI sound emulation core

View File

@ -1,8 +1,8 @@
/* /*
License: BSD-3-Clause 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 Seta/Allumer X1-010 Emulation core
the chip has 16 voices, all voices can be switchable to Wavetable or PCM sample playback mode. the chip has 16 voices, all voices can be switchable to Wavetable or PCM sample playback mode.

View File

@ -1,8 +1,8 @@
/* /*
License: BSD-3-Clause 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 Seta/Allumer X1-010 Emulation core
See x1_010.cpp for more info. See x1_010.cpp for more info.

View File

@ -213,7 +213,7 @@ void DivPlatformSoundUnit::tick(bool sysTick) {
DivInstrument* ins=parent->getIns(chan[i].ins,DIV_INS_SU); DivInstrument* ins=parent->getIns(chan[i].ins,DIV_INS_SU);
DivSample* sample=parent->getSample(ins->amiga.getSample(chan[i].note)); DivSample* sample=parent->getSample(ins->amiga.getSample(chan[i].note));
if (sample!=NULL) { 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; unsigned int off=sample->offSU+chan[i].hasOffset;
chan[i].hasOffset=0; chan[i].hasOffset=0;
if (sampleEnd>=getSampleMemCapacity(0)) sampleEnd=getSampleMemCapacity(0)-1; if (sampleEnd>=getSampleMemCapacity(0)) sampleEnd=getSampleMemCapacity(0)-1;
@ -221,7 +221,7 @@ void DivPlatformSoundUnit::tick(bool sysTick) {
chWrite(i,0x0b,off>>8); chWrite(i,0x0b,off>>8);
chWrite(i,0x0c,sampleEnd&0xff); chWrite(i,0x0c,sampleEnd&0xff);
chWrite(i,0x0d,sampleEnd>>8); chWrite(i,0x0d,sampleEnd>>8);
if (s->isLoopable()) { if (sample->isLoopable()) {
unsigned int sampleLoop=sample->offSU+sample->loopStart; unsigned int sampleLoop=sample->offSU+sample->loopStart;
if (sampleLoop>=getSampleMemCapacity(0)) sampleLoop=getSampleMemCapacity(0)-1; if (sampleLoop>=getSampleMemCapacity(0)) sampleLoop=getSampleMemCapacity(0)-1;
chWrite(i,0x0e,sampleLoop&0xff); chWrite(i,0x0e,sampleLoop&0xff);

View File

@ -344,7 +344,7 @@ void putDispatchChan(void* data, int chanNum, int type) {
ImGui::Text(" - pitch2: %d",ch->pitch2); ImGui::Text(" - pitch2: %d",ch->pitch2);
ImGui::Text("* note: %d",ch->note); ImGui::Text("* note: %d",ch->note);
ImGui::Text(" - next: %d",ch->nextNote); 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("- ins: %d",ch->ins);
ImGui::Text("- wave: %d",ch->wave); ImGui::Text("- wave: %d",ch->wave);
ImGui::Text("- VolMacroMax: %d",ch->volMacroMax); ImGui::Text("- VolMacroMax: %d",ch->volMacroMax);

View File

@ -2587,252 +2587,289 @@ void FurnaceGUI::drawInsEdit() {
P(ImGui::Checkbox("Don't test/gate before new note",&ins->c64.noTest)); P(ImGui::Checkbox("Don't test/gate before new note",&ins->c64.noTest));
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ins->type==DIV_INS_AMIGA || ins->type==DIV_INS_ES5506) if (ImGui::BeginTabItem("Sample")) { if (ins->type==DIV_INS_AMIGA || ins->type==DIV_INS_ES5506) {
String sName; if (ImGui::BeginTabItem("Sample")) {
if (ins->amiga.initSample<0 || ins->amiga.initSample>=e->song.sampleLen) { String sName;
sName="none selected"; if (ins->amiga.initSample<0 || ins->amiga.initSample>=e->song.sampleLen) {
} else { sName="none selected";
sName=e->song.sample[ins->amiga.initSample]->name; } else {
} sName=e->song.sample[ins->amiga.initSample]->name;
if (ImGui::BeginCombo("Initial Sample",sName.c_str())) { }
String id; if (ImGui::BeginCombo("Initial Sample",sName.c_str())) {
for (int i=0; i<e->song.sampleLen; i++) { String id;
id=fmt::sprintf("%d: %s",i,e->song.sample[i]->name); for (int i=0; i<e->song.sampleLen; i++) {
if (ImGui::Selectable(id.c_str(),ins->amiga.initSample==i)) { PARAMETER id=fmt::sprintf("%d: %s",i,e->song.sample[i]->name);
ins->amiga.initSample=i; 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::EndDisabled();
} // Note map
ImGui::BeginDisabled(ins->amiga.useWave); ImGui::BeginDisabled(ins->amiga.useWave||ins->amiga.transWave.enable);
P(ImGui::Checkbox("Reversed playback",&ins->amiga.reversed)); P(ImGui::Checkbox("Use sample map (does not work yet!)",&ins->amiga.useNoteMap));
ImGui::EndDisabled(); if (ins->amiga.useNoteMap) {
// Wavetable if (ImGui::BeginTable("NoteMap",4,ImGuiTableFlags_ScrollY|ImGuiTableFlags_Borders|ImGuiTableFlags_SizingStretchSame)) {
ImGui::BeginDisabled(ins->amiga.useNoteMap||ins->amiga.transWave.enable); ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed);
P(ImGui::Checkbox("Use wavetable (Amiga only)",&ins->amiga.useWave)); ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch);
if (ins->amiga.useWave) { ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch);
int len=ins->amiga.waveLen+1; ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthStretch);
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::TableSetupScrollFreeze(0,1); ImGui::TableSetupScrollFreeze(0,1);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); 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::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text("%s",noteNames[60+i]);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
if (ins->amiga.noteMap[i].ind<0 || ins->amiga.noteMap[i].ind>=e->song.sampleLen) { ImGui::Text("Sample");
sName="-- empty --"; ImGui::TableNextColumn();
ins->amiga.noteMap[i].ind=-1; ImGui::Text("Frequency");
} else { ImGui::TableNextColumn();
sName=e->song.sample[ins->amiga.noteMap[i].ind]->name; ImGui::Text("Reversed");
} for (int i=0; i<120; i++) {
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); ImGui::TableNextRow();
if (ImGui::BeginCombo(fmt::sprintf("##SampleMap_Index_%d",i).c_str(),sName.c_str())) { ImGui::PushID(fmt::sprintf("NM_%d",i).c_str());
String id; ImGui::TableNextColumn();
if (ImGui::Selectable("-- empty --",ins->amiga.noteMap[i].ind==-1)) { PARAMETER 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; ins->amiga.noteMap[i].ind=-1;
} else {
sName=e->song.sample[ins->amiga.noteMap[i].ind]->name;
} }
for (int j=0; j<e->song.sampleLen; j++) { ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
id=fmt::sprintf("%d: %s",j,e->song.sample[j]->name); if (ImGui::BeginCombo(fmt::sprintf("##SampleMap_Index_%d",i).c_str(),sName.c_str())) {
if (ImGui::Selectable(id.c_str(),ins->amiga.noteMap[i].ind==j)) { PARAMETER String id;
ins->amiga.noteMap[i].ind=j; if (ImGui::Selectable("-- empty --",ins->amiga.noteMap[i].ind==-1)) { PARAMETER
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)); ins->amiga.noteMap[i].ind=-1;
}
for (int j=0; j<e->song.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();
} }
} }
} DivInstrumentAmiga::TransWaveMap ind=ins->amiga.transWaveMap[ins->amiga.transWave.ind];
if (ImGui::InputInt("Initial Transwave Index##TransWaveInit",&ins->amiga.transWave.ind,1,16)) { PARAMETER if (ins->amiga.transWave.sliceEnable && (ind.ind>=0 && ind.ind<e->song.sampleLen)) {
if (ins->amiga.transWave.ind<1) ins->amiga.transWave.ind=0; ins->amiga.transWave.slicePos((double)(ins->amiga.transWave.slice)/4095.0);
if (ins->amiga.transWave.ind>=(int)(ins->amiga.transWaveMap.size())) ins->amiga.transWave.ind=ins->amiga.transWaveMap.size()-1; double sliceStart=ins->amiga.transWave.sliceStart;
} double sliceEnd=ins->amiga.transWave.sliceEnd;
P(ImGui::Checkbox("Use Transwave Slice##UseTransWaveSlice",&ins->amiga.transWave.sliceEnable)); 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
DivInstrumentAmiga::TransWaveMap ind=ins->amiga.transWaveMap[ins->amiga.transWave.ind]; ins->amiga.transWave.slicePos((double)(ins->amiga.transWave.slice)/4095.0);
if (ins->amiga.transWave.sliceEnable && (ind.ind>=0 && ind.ind<e->song.sampleLen)) { } rightClickable
double sliceInit=(double)(ins->amiga.transWave.slice)/4095.0; }
double slicePos=ins->amiga.transWave.slicePos(sliceInit); if (ImGui::BeginTable("TransWaveMap",6,ImGuiTableFlags_ScrollY|ImGuiTableFlags_Borders|ImGuiTableFlags_SizingStretchSame)) {
double sliceStart=ins->amiga.transWave.sliceStart; ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed); // Number
double sliceEnd=ins->amiga.transWave.sliceEnd; ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch); // Sample index
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::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch); // Loop start
ImGui::Text("Position: %.6f", slicePos); ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthStretch); // Loop end
} ImGui::TableSetupColumn("c4",ImGuiTableColumnFlags_WidthStretch); // Loop mode
if (ImGui::BeginTable("TransWaveMap",6,ImGuiTableFlags_ScrollY|ImGuiTableFlags_Borders|ImGuiTableFlags_SizingStretchSame)) { ImGui::TableSetupColumn("c5",ImGuiTableColumnFlags_WidthStretch); // Reversed
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::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; i<ins->amiga.transWaveMap.size(); i++) {
DivInstrumentAmiga::TransWaveMap& transWaveMap=ins->amiga.transWaveMap[i];
ImGui::TableNextRow();
ImGui::PushID(fmt::sprintf("TransWaveMap_%d",i).c_str());
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text("%d",(int)(i));
ImGui::TableNextColumn(); ImGui::TableNextColumn();
if (transWaveMap.ind<0 || transWaveMap.ind>=e->song.sampleLen) { ImGui::Text("Sample");
sName="-- empty --"; ImGui::TableNextColumn();
transWaveMap.ind=-1; ImGui::Text("Loop Start");
} else { ImGui::TableNextColumn();
sName=e->song.sample[transWaveMap.ind]->name; ImGui::Text("Loop End");
} ImGui::TableNextColumn();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); ImGui::Text("Loop Mode");
if (ImGui::BeginCombo(fmt::sprintf("##TransWaveMap_Index_%d",i).c_str(),sName.c_str())) { ImGui::TableNextColumn();
String id; ImGui::Text("Reversed");
if (ImGui::Selectable("-- empty --",transWaveMap.ind==-1)) { PARAMETER for (size_t i=0; i<ins->amiga.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; transWaveMap.ind=-1;
} else {
sName=e->song.sample[transWaveMap.ind]->name;
} }
for (int j=0; j<e->song.sampleLen; j++) { ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
DivSample* s=e->song.sample[j]; if (ImGui::BeginCombo(fmt::sprintf("##TransWaveMap_Index_%d",i).c_str(),sName.c_str())) {
id=fmt::sprintf("%d: %s",j,s->name); String id;
if (ImGui::Selectable(id.c_str(),transWaveMap.ind==j)) { PARAMETER if (ImGui::Selectable("-- empty --",transWaveMap.ind==-1)) { PARAMETER
transWaveMap.ind=j; transWaveMap.ind=-1;
if (transWaveMap.loopStart<0 || transWaveMap.loopStart>(int)(s->samples)) { }
transWaveMap.loopStart=s->loopStart; for (int j=0; j<e->song.sampleLen; j++) {
} DivSample* s=e->song.sample[j];
if (transWaveMap.loopEnd<0 || transWaveMap.loopEnd>(int)(s->samples)) { id=fmt::sprintf("%d: %s",j,s->name);
transWaveMap.loopEnd=s->loopEnd; 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.ind<e->song.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); 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::TableNextColumn();
} ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
ImGui::BeginDisabled(transWaveMap.ind<0 || transWaveMap.ind>=e->song.sampleLen); if (ImGui::InputInt(fmt::sprintf("##TransWaveMap_LoopEnd_%d",i).c_str(),&transWaveMap.loopEnd,256,4096)) { PARAMETER
ImGui::TableNextColumn(); if (transWaveMap.ind>=0 && transWaveMap.ind<e->song.sampleLen) {
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); DivSample* s=e->song.sample[transWaveMap.ind];
if (ImGui::InputInt(fmt::sprintf("##TransWaveMap_LoopStart_%d",i).c_str(),&transWaveMap.loopStart,256,4096)) { PARAMETER if (transWaveMap.loopEnd<transWaveMap.loopStart) transWaveMap.loopEnd=transWaveMap.loopStart;
if (transWaveMap.ind>=0 && transWaveMap.ind<e->song.sampleLen) { if (transWaveMap.loopEnd>(int)(s->samples)) transWaveMap.loopEnd=s->samples;
DivSample* s=e->song.sample[transWaveMap.ind]; transWaveMap.updateSize(s->samples,transWaveMap.loopStart,transWaveMap.loopEnd);
if (transWaveMap.loopStart<0) transWaveMap.loopStart=0; if (ins->amiga.transWave.sliceEnable) {
if (transWaveMap.loopStart>transWaveMap.loopEnd) transWaveMap.loopStart=transWaveMap.loopEnd; ins->amiga.transWave.updateSize(s->samples,transWaveMap.loopStart,transWaveMap.loopEnd);
transWaveMap.updateSize(s->samples,transWaveMap.loopStart,transWaveMap.loopEnd); ins->amiga.transWave.slicePos((double)(ins->amiga.transWave.slice)/4095.0);
}
}
} }
} ImGui::TableNextColumn();
ImGui::TableNextColumn(); if (ImGui::RadioButton(fmt::sprintf("Forward##TransWaveMap_LoopMode_Forward_%d",i).c_str(),transWaveMap.loopMode==DIV_SAMPLE_LOOPMODE_FORWARD)) { MARK_MODIFIED
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); transWaveMap.loopMode=DIV_SAMPLE_LOOPMODE_FORWARD;
if (ImGui::InputInt(fmt::sprintf("##TransWaveMap_LoopEnd_%d",i).c_str(),&transWaveMap.loopEnd,256,4096)) { PARAMETER
if (transWaveMap.ind>=0 && transWaveMap.ind<e->song.sampleLen) {
DivSample* s=e->song.sample[transWaveMap.ind];
if (transWaveMap.loopEnd<transWaveMap.loopStart) transWaveMap.loopEnd=transWaveMap.loopStart;
if (transWaveMap.loopEnd>(int)(s->samples)) transWaveMap.loopEnd=s->samples;
transWaveMap.updateSize(s->samples,transWaveMap.loopStart,transWaveMap.loopEnd);
} }
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(); ImGui::EndTable();
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::EndDisabled();
ImGui::EndTabItem();
}
if (ins->amiga.transWave.enable) {
if (ImGui::BeginTabItem("Transwave Macros")) { 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 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])); macroList.push_back(FurnaceGUIMacroDesc("Transwave slice",&ins->std.fmsMacro,0,4095,160,uiColors[GUI_COLOR_MACRO_OTHER]));
drawMacros(macroList);
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
} }
ImGui::EndDisabled();
ImGui::EndTabItem();
} }
if (ins->type==DIV_INS_N163) if (ImGui::BeginTabItem("Namco 163")) { if (ins->type==DIV_INS_N163) if (ImGui::BeginTabItem("Namco 163")) {
if (ImGui::InputInt("Waveform##WAVE",&ins->n163.wave,1,10)) { PARAMETER if (ImGui::InputInt("Waveform##WAVE",&ins->n163.wave,1,10)) { PARAMETER