Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing pitch envelope export and improving auto pitch envelope #488

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
13 changes: 10 additions & 3 deletions hi_core/hi_sampler/sampler/components/SampleEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,22 +403,29 @@ struct EnvelopePopup : public Component
y += 0.5;

y = 0.5 * (1.0 - intensity) + intensity * y;

list.add({ x, y });
}

numToDo -= numSamplesToUse;
offset += numSamplesToUse;
}

if (!list.isEmpty())
{
auto f = [list](Table& t)
{
t.reset();
t.setTablePoint(0, 0.0f, 0.5f, 0.5f);
t.setTablePoint(1, 0.0f, 0.5f, 0.5f);

for (auto p : list)
t.addTablePoint(p.x, p.y);
{
if (p.y != 0.0 && p.y != 1.0)
t.addTablePoint(p.x, p.y);
}

t.setTablePoint(0, 0.0f, t.getGraphPoint(1).y, 0.5f);

return true;
};
Expand Down
6 changes: 3 additions & 3 deletions hi_lac/hlac/CompressionHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ void CompressionHelpers::dump(const AudioBufferInt16& b, String fileName)
}


void CompressionHelpers::dump(const AudioSampleBuffer& b, String fileName)
void CompressionHelpers::dump(const AudioSampleBuffer& b, String fileName, double sampleRate, int bitDepth)
{
WavAudioFormat afm;

Expand All @@ -498,7 +498,7 @@ void CompressionHelpers::dump(const AudioSampleBuffer& b, String fileName)

if (File::isAbsolutePath(fileName))
{
dumpFile = File(fileName);
dumpFile = File(fileName);
}
else
{
Expand All @@ -523,7 +523,7 @@ void CompressionHelpers::dump(const AudioSampleBuffer& b, String fileName)

FileOutputStream* fis = new FileOutputStream(dumpFile);
StringPairArray metadata;
ScopedPointer<AudioFormatWriter> writer = afm.createWriterFor(fis, 44100, b.getNumChannels(), 16, metadata, 5);
ScopedPointer<AudioFormatWriter> writer = afm.createWriterFor(fis, sampleRate, b.getNumChannels(), bitDepth, metadata, 5);

if (writer != nullptr)
writer->writeFromAudioSampleBuffer(b, 0, b.getNumSamples());
Expand Down
2 changes: 1 addition & 1 deletion hi_lac/hlac/CompressionHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ struct CompressionHelpers

static void dump(const AudioBufferInt16& b, String fileName=String());

static void dump(const AudioSampleBuffer& b, String fileName = String());
static void dump(const AudioSampleBuffer& b, String fileName = String(), double sampleRate = 44100, int bitDepth = 16);

static void fastInt16ToFloat(const void* source, float* destination, int numSamples);

Expand Down