Skip to content

Commit

Permalink
- added variable threshhold level & mic position for sample start tri…
Browse files Browse the repository at this point in the history
…m function
  • Loading branch information
christoph-hart committed Oct 14, 2017
1 parent 61660de commit 583b615
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions hi_sampler/sampler/components/SampleEditingActions.cpp
Expand Up @@ -1068,6 +1068,21 @@ void SampleEditHandler::SampleEditingActions::trimSampleStart(SampleEditHandler
{
Array<WeakReference<ModulatorSamplerSound>> sounds = handler->getSelection().getItemArray();

int multiMicIndex = 0;

int micPositions = handler->getSampler()->getNumMicPositions();

if(micPositions > 1)
{
multiMicIndex = jlimit(0, micPositions-1, PresetHandler::getCustomName("Channel Index", "Enter the channel index (starting with 0) for the mic position that you want to use to detect the sample start").getIntValue());
}

float dBThreshold = PresetHandler::getCustomName("Threshold", "Enter the dB Value for the threshold (it will use this as difference to the peak level").getFloatValue();

dBThreshold = jlimit<float>(-100.0f, 0.0f, dBThreshold);



ModulatorSampler *sampler = handler->getSampler();

sampler->getUndoManager()->beginNewTransaction();
Expand All @@ -1078,7 +1093,7 @@ void SampleEditHandler::SampleEditingActions::trimSampleStart(SampleEditHandler
{
if (sounds[i].get() != nullptr)
{
AudioFormatReader* reader = sounds[i]->getReferenceToSound()->createReaderForAnalysis();
AudioFormatReader* reader = sounds[i]->getReferenceToSound(multiMicIndex)->createReaderForAnalysis();

if (reader != nullptr)
{
Expand All @@ -1096,9 +1111,7 @@ void SampleEditHandler::SampleEditingActions::trimSampleStart(SampleEditHandler

const float maxLevel = jmax<float>(std::fabs(lLow), std::fabs(lHigh), std::fabs(rLow), std::fabs(rHigh));

const float dBThreshhold = -18.0f;

const float threshHoldLevel = Decibels::decibelsToGain(dBThreshhold) * maxLevel;
const float threshHoldLevel = Decibels::decibelsToGain(dBThreshold) * maxLevel;

int sample = sounds[i]->getProperty(ModulatorSamplerSound::SampleStart);

Expand Down

0 comments on commit 583b615

Please sign in to comment.