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 13, 2023
1 parent 82dffed commit bece5e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
9 changes: 3 additions & 6 deletions test1/editorevents.d
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,11 @@ public class AddSampleFile : UndoableEvent {
int sampleID;
string path;
Tag backup;
public this (ModuleConfig mcfg, string modID, int sampleID, string path, Tag backup) {
public this (ModuleConfig mcfg, string modID, int sampleID, string path) {
this.mcfg = mcfg;
this.modID = modID;
this.sampleID = sampleID;
this.path = path;
this.backup = backup;
}
public void redo() {
if (backup is null) {
Expand All @@ -209,14 +208,13 @@ public class AddSampleSlice : UndoableEvent {
int begin;
int len;
Tag backup;
public this (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) {
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) {
Expand All @@ -234,11 +232,10 @@ public class RemoveSample : UndoableEvent {
string modID;
int sampleID;
Tag backup;
public this (ModuleConfig mcfg, string modID, int sampleID, Tag backup) {
public this (ModuleConfig mcfg, string modID, int sampleID) {
this.mcfg = mcfg;
this.modID = modID;
this.sampleID = sampleID;
this.backup = backup;
}
public void redo() {
backup = mcfg.removeWave(modID, sampleID);
Expand Down
19 changes: 14 additions & 5 deletions test1/sampleman.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import pixelperfectengine.audio.base.config;
import std.math : floor;
import std.conv;
import test1.app;
import test1.editorevents;

public class WaveformViewer : WindowElement {
int[] waveform;
Expand Down Expand Up @@ -93,8 +94,9 @@ public class SampleMan : Window {

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

super(Box(0, 0, 520, 322), "Sample manager ["d ~ moduleName.to!dstring ~ "]"d);
listView_sampleList = new ListView(new ListViewHeader(16, [40 ,250], ["ID" ,"file source"]), null, "listView0",
Expand Down Expand Up @@ -136,9 +138,12 @@ public class SampleMan : Window {
}
protected void onSampleCreate(Text tx) {
try {
int sampleID = to!int(tx.toDString);
const int sampleID = to!int(tx.toDString);
//check if sample exists

foreach (WaveFileData key; waveFileData) {
if (key.id == sampleID) return;
}
adk.eventStack.addToTop(new AddSampleFile(adk.mcfg, moduleName, sampleID, path));
} catch (Exception e) {

}
Expand All @@ -147,7 +152,11 @@ public class SampleMan : Window {
handler.addWindow(new SliceDialog(&onSliceCreate));
}
protected void onSliceCreate(int id, int begin, int end) {

if (listView_sampleList >= 0) {
const int src = waveFileData[listView_sampleList.value];
const int len = end - begin;
adk.eventStack.addToTop(new AddSampleSlice(adk.mcfg, moduleName, id, begin, len));
}
}
protected void button_remove_onClick(Event ev) {

Expand Down

0 comments on commit bece5e2

Please sign in to comment.