Skip to content

Commit

Permalink
Work on sample management system
Browse files Browse the repository at this point in the history
  • Loading branch information
ZILtoid1991 committed Jul 12, 2023
1 parent 7593295 commit 82dffed
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 4 deletions.
67 changes: 64 additions & 3 deletions test1/editorevents.d
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,72 @@ public class RemovePresetEvent : UndoableEvent {
}
}
public class AddSampleFile : UndoableEvent {

ModuleConfig mcfg;
string modID;
int sampleID;
string path;
Tag backup;
public this (ModuleConfig mcfg, string modID, int sampleID, string path, Tag backup) {
this.mcfg = mcfg;
this.modID = modID;
this.sampleID = sampleID;
this.path = path;
this.backup = backup;
}
public void redo() {
if (backup is null) {
mcfg.addWaveFile(path, modID, sampleID, null, null);
} else {
mcfg.addWaveFromBackup(path, backup);
}
}
public void undo() {
backup = mcfg.removeWave(modID, sampleID);
}
}
public class AddSampleSlice : UndoableEvent {

ModuleConfig mcfg;
string modID;
int sampleID;
int src;
int begin;
int len;
Tag backup;
public this (ModuleConfig mcfg, string modID, int sampleID, int src, int begin, int len, Tag backup) {
this.mcfg = mcfg;
this.modID = modID;
this.sampleID = sampleID;
this.src = src;
this.begin = begin;
this.len = len;
this.backup = backup;
}
public void redo() {
if (backup is null) {
mcfg.addWaveSlice(modID, sampleID, src, begin, len, null);
} else {
mcfg.addWaveFromBackup(path, backup);
}
}
public void undo() {
backup = mcfg.removeWave(modID, sampleID);
}
}
public class RemoveSample : UndoableEvent {

ModuleConfig mcfg;
string modID;
int sampleID;
Tag backup;
public this (ModuleConfig mcfg, string modID, int sampleID, Tag backup) {
this.mcfg = mcfg;
this.modID = modID;
this.sampleID = sampleID;
this.backup = backup;
}
public void redo() {
backup = mcfg.removeWave(modID, sampleID);
}
public void undo() {
mcfg.addWaveFromBackup(path, backup);
}
}
5 changes: 4 additions & 1 deletion test1/sampleman.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import pixelperfectengine.audio.base.func;
import pixelperfectengine.audio.base.config;
import std.math : floor;
import std.conv;
import test1.app;

public class WaveformViewer : WindowElement {
int[] waveform;
Expand Down Expand Up @@ -84,13 +85,15 @@ public class SampleMan : Window {
Label label_slmpR;
Label label_len;
WaveformViewer wfv;

AudioDevKit adk;

WaveFileData[] waveFileData;
string path;

string moduleName;
//TextBox textBox0;
public this(string moduleName){
public this(string moduleName, AudioDevKit adk){
this.moduleName = moduleName;

super(Box(0, 0, 520, 322), "Sample manager ["d ~ moduleName.to!dstring ~ "]"d);
Expand Down

0 comments on commit 82dffed

Please sign in to comment.