Skip to content

Commit

Permalink
When applying sample map properties, use sample rate and bit depth of…
Browse files Browse the repository at this point in the history
… original audio files
  • Loading branch information
davidhealey committed Feb 25, 2024
1 parent c4d33d0 commit ca130db
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions hi_backend/backend/BackendApplicationCommandWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,14 @@ class SampleMapPropertySaverWithBackup : public DialogWindowWithBackgroundThread
int numChannels = ob.getNumChannels();
int numSamples = ob.getNumSamples();

AudioFormatManager afm;
afm.registerBasicFormats(); // Register basic audio formats

std::unique_ptr<AudioFormatReader> reader(afm.createReaderFor(fileToUse));

double sampleRate = reader->sampleRate;
int bitDepth = reader->bitsPerSample;

fileToUse.deleteFile();

AudioSampleBuffer lut;
Expand Down Expand Up @@ -2370,8 +2378,8 @@ class SampleMapPropertySaverWithBackup : public DialogWindowWithBackgroundThread
CascadedEnvelopeLowPass lp(true);

PrepareSpecs ps;
ps.blockSize = 16;
ps.sampleRate = 44100.0;
ps.blockSize = bitDepth;
ps.sampleRate = sampleRate;
ps.numChannels = numChannels;

lp.prepare(ps);
Expand All @@ -2388,7 +2396,7 @@ class SampleMapPropertySaverWithBackup : public DialogWindowWithBackgroundThread
}

propertyData.removeProperty(id, nullptr);
hlac::CompressionHelpers::dump(ob, fileToUse.getFullPathName());
hlac::CompressionHelpers::dump(ob, fileToUse.getFullPathName(), sampleRate, bitDepth);
}

ValueTree propertyData;
Expand Down

0 comments on commit ca130db

Please sign in to comment.