mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-27 06:53:01 +00:00
Struct-ize sample map variable
This commit is contained in:
parent
dff7c61b79
commit
a5959ae7b9
4 changed files with 40 additions and 24 deletions
|
@ -2445,8 +2445,8 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len) {
|
||||||
|
|
||||||
const int dpcmNotes=(blockVersion>=2)?96:72;
|
const int dpcmNotes=(blockVersion>=2)?96:72;
|
||||||
for (int j=0; j<dpcmNotes; j++) {
|
for (int j=0; j<dpcmNotes; j++) {
|
||||||
ins->amiga.noteMap[j]=(short)((unsigned char)reader.readC())-1;
|
ins->amiga.noteMap[j].map=(short)((unsigned char)reader.readC())-1;
|
||||||
ins->amiga.noteFreq[j]=(unsigned char)reader.readC();
|
ins->amiga.noteMap[j].freq=(unsigned char)reader.readC();
|
||||||
if (blockVersion>=6) {
|
if (blockVersion>=6) {
|
||||||
reader.readC(); // DMC value
|
reader.readC(); // DMC value
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,8 +387,12 @@ void DivInstrument::putInsData(SafeWriter* w) {
|
||||||
// sample map
|
// sample map
|
||||||
w->writeC(amiga.useNoteMap);
|
w->writeC(amiga.useNoteMap);
|
||||||
if (amiga.useNoteMap) {
|
if (amiga.useNoteMap) {
|
||||||
w->write(amiga.noteFreq,120*sizeof(unsigned int));
|
for (int note=0; note<120; note++) {
|
||||||
w->write(amiga.noteMap,120*sizeof(short));
|
w->writeI(amiga.noteMap[note].freq);
|
||||||
|
}
|
||||||
|
for (int note=0; note<120; note++) {
|
||||||
|
w->writeS(amiga.noteMap[note].map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// N163
|
// N163
|
||||||
|
@ -932,8 +936,12 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
|
||||||
if (version>=67) {
|
if (version>=67) {
|
||||||
amiga.useNoteMap=reader.readC();
|
amiga.useNoteMap=reader.readC();
|
||||||
if (amiga.useNoteMap) {
|
if (amiga.useNoteMap) {
|
||||||
reader.read(amiga.noteFreq,120*sizeof(unsigned int));
|
for (int note=0; note<120; note++) {
|
||||||
reader.read(amiga.noteMap,120*sizeof(short));
|
amiga.noteMap[note].freq=reader.readI();
|
||||||
|
}
|
||||||
|
for (int note=0; note<120; note++) {
|
||||||
|
amiga.noteMap[note].map=reader.readS();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -306,12 +306,18 @@ struct DivInstrumentC64 {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DivInstrumentAmiga {
|
struct DivInstrumentAmiga {
|
||||||
|
struct SampleMap {
|
||||||
|
int freq;
|
||||||
|
short map;
|
||||||
|
SampleMap(int f=0, short m=-1):
|
||||||
|
freq(f),
|
||||||
|
map(m) {}
|
||||||
|
};
|
||||||
short initSample;
|
short initSample;
|
||||||
bool useNoteMap;
|
bool useNoteMap;
|
||||||
bool useWave;
|
bool useWave;
|
||||||
unsigned char waveLen;
|
unsigned char waveLen;
|
||||||
int noteFreq[120];
|
SampleMap noteMap[120];
|
||||||
short noteMap[120];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the sample at specified note.
|
* get the sample at specified note.
|
||||||
|
@ -321,7 +327,7 @@ struct DivInstrumentAmiga {
|
||||||
if (useNoteMap) {
|
if (useNoteMap) {
|
||||||
if (note<0) note=0;
|
if (note<0) note=0;
|
||||||
if (note>119) note=119;
|
if (note>119) note=119;
|
||||||
return noteMap[note];
|
return noteMap[note].map;
|
||||||
}
|
}
|
||||||
return initSample;
|
return initSample;
|
||||||
}
|
}
|
||||||
|
@ -334,7 +340,7 @@ struct DivInstrumentAmiga {
|
||||||
if (useNoteMap) {
|
if (useNoteMap) {
|
||||||
if (note<0) note=0;
|
if (note<0) note=0;
|
||||||
if (note>119) note=119;
|
if (note>119) note=119;
|
||||||
return noteFreq[note];
|
return noteMap[note].freq;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -344,8 +350,9 @@ struct DivInstrumentAmiga {
|
||||||
useNoteMap(false),
|
useNoteMap(false),
|
||||||
useWave(false),
|
useWave(false),
|
||||||
waveLen(31) {
|
waveLen(31) {
|
||||||
memset(noteMap,-1,120*sizeof(short));
|
for (SampleMap& elem: noteMap) {
|
||||||
memset(noteFreq,0,120*sizeof(int));
|
elem=SampleMap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3011,7 +3011,7 @@ void FurnaceGUI::drawInsEdit() {
|
||||||
if (ImGui::BeginTable("NoteMap",2,ImGuiTableFlags_ScrollY|ImGuiTableFlags_Borders|ImGuiTableFlags_SizingStretchSame)) {
|
if (ImGui::BeginTable("NoteMap",2,ImGuiTableFlags_ScrollY|ImGuiTableFlags_Borders|ImGuiTableFlags_SizingStretchSame)) {
|
||||||
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed);
|
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed);
|
||||||
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch);
|
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch);
|
||||||
ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch);
|
//ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch);
|
||||||
|
|
||||||
ImGui::TableSetupScrollFreeze(0,1);
|
ImGui::TableSetupScrollFreeze(0,1);
|
||||||
|
|
||||||
|
@ -3022,37 +3022,38 @@ void FurnaceGUI::drawInsEdit() {
|
||||||
/*ImGui::TableNextColumn();
|
/*ImGui::TableNextColumn();
|
||||||
ImGui::Text("Frequency");*/
|
ImGui::Text("Frequency");*/
|
||||||
for (int i=0; i<120; i++) {
|
for (int i=0; i<120; i++) {
|
||||||
|
DivInstrumentAmiga::SampleMap sampleMap=ins->amiga.noteMap[i];
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::PushID(fmt::sprintf("NM_%d",i).c_str());
|
ImGui::PushID(fmt::sprintf("NM_%d",i).c_str());
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text("%s",noteNames[60+i]);
|
ImGui::Text("%s",noteNames[60+i]);
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if (ins->amiga.noteMap[i]<0 || ins->amiga.noteMap[i]>=e->song.sampleLen) {
|
if (sampleMap.map<0 || sampleMap.map>=e->song.sampleLen) {
|
||||||
sName="-- empty --";
|
sName="-- empty --";
|
||||||
ins->amiga.noteMap[i]=-1;
|
sampleMap.map=-1;
|
||||||
} else {
|
} else {
|
||||||
sName=e->song.sample[ins->amiga.noteMap[i]]->name;
|
sName=e->song.sample[sampleMap.map]->name;
|
||||||
}
|
}
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||||
if (ImGui::BeginCombo("##SM",sName.c_str())) {
|
if (ImGui::BeginCombo("##SM",sName.c_str())) {
|
||||||
String id;
|
String id;
|
||||||
if (ImGui::Selectable("-- empty --",ins->amiga.noteMap[i]==-1)) { PARAMETER
|
if (ImGui::Selectable("-- empty --",sampleMap.map==-1)) { PARAMETER
|
||||||
ins->amiga.noteMap[i]=-1;
|
sampleMap.map=-1;
|
||||||
}
|
}
|
||||||
for (int j=0; j<e->song.sampleLen; j++) {
|
for (int j=0; j<e->song.sampleLen; j++) {
|
||||||
id=fmt::sprintf("%d: %s",j,e->song.sample[j]->name);
|
id=fmt::sprintf("%d: %s",j,e->song.sample[j]->name);
|
||||||
if (ImGui::Selectable(id.c_str(),ins->amiga.noteMap[i]==j)) { PARAMETER
|
if (ImGui::Selectable(id.c_str(),sampleMap.map==j)) { PARAMETER
|
||||||
ins->amiga.noteMap[i]=j;
|
sampleMap.map=j;
|
||||||
if (ins->amiga.noteFreq[i]<=0) ins->amiga.noteFreq[i]=(int)((double)e->song.sample[j]->centerRate*pow(2.0,((double)i-48.0)/12.0));
|
if (sampleMap.freq<=0) sampleMap.freq=(int)((double)e->song.sample[j]->centerRate*pow(2.0,((double)i-48.0)/12.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
/*ImGui::TableNextColumn();
|
/*ImGui::TableNextColumn();
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||||
if (ImGui::InputInt("##SF",&ins->amiga.noteFreq[i],50,500)) { PARAMETER
|
if (ImGui::InputInt("##SF",&sampleMap.freq,50,500)) { PARAMETER
|
||||||
if (ins->amiga.noteFreq[i]<0) ins->amiga.noteFreq[i]=0;
|
if (sampleMap.freq<0) sampleMap.freq=0;
|
||||||
if (ins->amiga.noteFreq[i]>262144) ins->amiga.noteFreq[i]=262144;
|
if (sampleMap.freq>262144) sampleMap.freq=262144;
|
||||||
}*/
|
}*/
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue