Skip to content

Commit

Permalink
Making delaylines working and not output NaNs
Browse files Browse the repository at this point in the history
  • Loading branch information
ZILtoid1991 committed Jul 26, 2023
1 parent 5cc5834 commit 2cfa853
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
19 changes: 16 additions & 3 deletions pixelperfectengine/src/pixelperfectengine/audio/base/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class ModuleConfig {
break;
case "delaylines":
import pixelperfectengine.audio.modules.delaylines;
currMod = new DelayLines(t0.expectTagValue!int("priLen"), t0.expectTagValue!int("secLen"));
currMod = new DelayLines(t0.values[2].get!int(), t0.values[3].get!int());
break;
default:
break;
Expand Down Expand Up @@ -303,7 +303,7 @@ public class ModuleConfig {
ubyte[] buf;
buf.length = cast(size_t)f.size();
f.rawRead(buf);
const int samplerate = extension(path) == ".voc" ? 8000 : 36_000;
const int samplerate = extension(path) == ".voc" || extension(path) == ".adp" ? 8000 : 36_000;
mod.waveformDataReceive(waveID, buf, WaveFormat(samplerate, samplerate / 2, AudioFormat.DIALOGIC_OKI_ADPCM, 1, 1, 4));
}
/**
Expand Down Expand Up @@ -465,7 +465,20 @@ public class ModuleConfig {
* name = Name and ID of the module.
*/
public void addModule(string type, string name) {
new Tag(root, null, "module", [Value(type), Value(name)]);
switch (type) {
case "delaylines1010":
new Tag(root, null, "module", [Value("delaylines"), Value(name), Value(1024), Value(1024)]);
break;
case "delaylines1012":
new Tag(root, null, "module", [Value("delaylines"), Value(name), Value(1024), Value(4096)]);
break;
case "delaylines1212":
new Tag(root, null, "module", [Value("delaylines"), Value(name), Value(4096), Value(4096)]);
break;
default:
new Tag(root, null, "module", [Value(type), Value(name)]);
break;
}
}
/**
* Adds a module from backup.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ public class DelayLines : AudioModule {
}
}
Tap[4][2] taps; ///Defines delay line taps
__m128[2] iirFreq; ///Defines IIR frequencies
__m128[2] iirQ; ///Defines IIR Q value
__m128[2] eqLevels; ///Stores EQ send levels
__m128 inputLevel;
__m128 oscLevels; ///Defines the amount of effect a given LFO has on a parameter
float[4] oscFrequencies; ///Defines LFO freqencies
__m128[2] iirFreq = [__m128([100, 500, 1000, 10_000]), __m128([100, 500, 1000, 10_000])];///Defines IIR frequencies
__m128[2] iirQ = [__m128(0.707), __m128(0.707)];///Defines IIR Q value
__m128[2] eqLevels = [__m128(0), __m128(0)];///Stores EQ send levels
__m128 inputLevel = __m128(1);
__m128 oscLevels = __m128(0);///Defines the amount of effect a given LFO has on a parameter
float[4] oscFrequencies = [4, 4, 4, 4];///Defines LFO freqencies
uint[4] oscPWM; ///Defines the PWM of the LFOs
float[2] outputLevel;
float[2] outputLevel = [1.0, 1.0];
ubyte[4] oscTargets; ///Sets the target of a given LFO
OscWaveform[4] oscWaveform; ///Sets the waveform output of the LFOs

Expand Down Expand Up @@ -181,6 +181,8 @@ public class DelayLines : AudioModule {
key = __m128i(0);
}
resetBuffer(dummyBuf);
filterBanks[0].reset();
filterBanks[1].reset();
}

override public void midiReceive(UMP data0, uint data1 = 0, uint data2 = 0, uint data3 = 0) @nogc nothrow {
Expand Down
7 changes: 5 additions & 2 deletions test1/modulerouter.d
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ public class ModuleRouter : Window {
}
}
private void button_addMod_onClick(Event e) {
handler.addPopUpElement(new PopUpMenu([new PopUpMenuElement("qm816", "QM816"), new PopUpMenuElement("pcm8", "PCM8")],
"moduleSelector", &onModuleTypeSelect));
handler.addPopUpElement(new PopUpMenu([new PopUpMenuElement("qm816", "QM816"), new PopUpMenuElement("pcm8", "PCM8"),
new PopUpMenuElement("delaylines1010", "DelayLines:1024/1024"),
new PopUpMenuElement("delaylines1012", "DelayLines:1024/4096"),
new PopUpMenuElement("delaylines1212", "DelayLines:4096/4964"),
], "moduleSelector", &onModuleTypeSelect));
}
private void button_preset_onClick(Event e) {
adk.openPresetEditor();
Expand Down

0 comments on commit 2cfa853

Please sign in to comment.