Commit fd217cef authored by jhammen's avatar jhammen
Browse files

allow per instrument sample base path

parent a868ee82
......@@ -279,6 +279,7 @@ Instrument *Plugin::loadInstrument(Json::Value &jsonInstr, uint16_t channel, flo
Instrument *instrument = new handrumr::Instrument();
instrument->name(jsonInstr["iname"].asString());
float instgain = jsonInstr.isMember("gain") ? jsonInstr["gain"].asFloat() : 0.0;
string instbase = jsonInstr.isMember("folder") ? jsonInstr["folder"].asString() : sampleBase;
// layers
Json::Value jsonLayers = jsonInstr["layers"];
uint16_t layerCount = jsonLayers.size();
......@@ -309,7 +310,7 @@ Instrument *Plugin::loadInstrument(Json::Value &jsonInstr, uint16_t channel, flo
uint16_t bufferCount = 0; // overall channel count for sample
for (uint16_t f = 0; f < fileCount; f++) {
const string &filename = jsamples[f]["file"].asString();
const string path = fullpath(sampleBase, filename);
const string path = fullpath(instbase, filename);
const float filegain =
jsamples[f].isMember("gain") ? jsamples[f]["gain"].asFloat() : 0.0;
const float gain = db2ratio(ogaindb + instgain + layergain + filegain);
......@@ -330,7 +331,7 @@ Instrument *Plugin::loadInstrument(Json::Value &jsonInstr, uint16_t channel, flo
SampleFileBuffer *buffers = new SampleFileBuffer[bufferCount];
uint16_t index = 0;
for (uint16_t f = 0; f < fileCount; f++) {
const string path = fullpath(sampleBase, jsamples[f]["file"].asString());
const string path = fullpath(instbase, jsamples[f]["file"].asString());
SampleFile *file = filecache[path];
uint64_t frames = file->frames();
for (uint16_t c = 0; c < bufferCount; c++) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment