Merge branch 'feature/volume-parameter' into develop
This commit is contained in:
commit
4d8032b354
4 changed files with 47 additions and 0 deletions
|
|
@ -143,6 +143,10 @@ void sfz::Synth::handleGlobalOpcodes(const std::vector<Opcode>& members)
|
||||||
case hash("sw_default"):
|
case hash("sw_default"):
|
||||||
setValueFromOpcode(member, defaultSwitch, Default::keyRange);
|
setValueFromOpcode(member, defaultSwitch, Default::keyRange);
|
||||||
break;
|
break;
|
||||||
|
case hash("volume"):
|
||||||
|
// FIXME : Probably best not to mess with this and let the host control the volume
|
||||||
|
// setValueFromOpcode(member, volume, Default::volumeRange);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -350,6 +354,8 @@ void sfz::Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
||||||
voice->renderBlock(tempSpan);
|
voice->renderBlock(tempSpan);
|
||||||
buffer.add(tempSpan);
|
buffer.add(tempSpan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buffer.applyGain(db2mag(volume));
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfz::Synth::noteOn(int delay, int channel, int noteNumber, uint8_t velocity) noexcept
|
void sfz::Synth::noteOn(int delay, int channel, int noteNumber, uint8_t velocity) noexcept
|
||||||
|
|
@ -492,3 +498,12 @@ size_t sfz::Synth::getNumPreloadedSamples() const noexcept
|
||||||
{
|
{
|
||||||
return filePool.getNumPreloadedSamples();
|
return filePool.getNumPreloadedSamples();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float sfz::Synth::getVolume() const noexcept
|
||||||
|
{
|
||||||
|
return volume;
|
||||||
|
}
|
||||||
|
void sfz::Synth::setVolume(float volume) noexcept
|
||||||
|
{
|
||||||
|
this->volume = Default::volumeRange.clamp(volume);
|
||||||
|
}
|
||||||
|
|
@ -51,6 +51,9 @@ public:
|
||||||
|
|
||||||
void setSamplesPerBlock(int samplesPerBlock) noexcept;
|
void setSamplesPerBlock(int samplesPerBlock) noexcept;
|
||||||
void setSampleRate(float sampleRate) noexcept;
|
void setSampleRate(float sampleRate) noexcept;
|
||||||
|
float getVolume() const noexcept;
|
||||||
|
void setVolume(float volume) noexcept;
|
||||||
|
|
||||||
void renderBlock(AudioSpan<float> buffer) noexcept;
|
void renderBlock(AudioSpan<float> buffer) noexcept;
|
||||||
void noteOn(int delay, int channel, int noteNumber, uint8_t velocity) noexcept;
|
void noteOn(int delay, int channel, int noteNumber, uint8_t velocity) noexcept;
|
||||||
void noteOff(int delay, int channel, int noteNumber, uint8_t velocity) noexcept;
|
void noteOff(int delay, int channel, int noteNumber, uint8_t velocity) noexcept;
|
||||||
|
|
@ -96,6 +99,7 @@ private:
|
||||||
AudioBuffer<float> tempBuffer { 2, config::defaultSamplesPerBlock };
|
AudioBuffer<float> tempBuffer { 2, config::defaultSamplesPerBlock };
|
||||||
int samplesPerBlock { config::defaultSamplesPerBlock };
|
int samplesPerBlock { config::defaultSamplesPerBlock };
|
||||||
float sampleRate { config::defaultSampleRate };
|
float sampleRate { config::defaultSampleRate };
|
||||||
|
float volume { Default::volume };
|
||||||
|
|
||||||
std::uniform_real_distribution<float> randNoteDistribution { 0, 1 };
|
std::uniform_real_distribution<float> randNoteDistribution { 0, 1 };
|
||||||
unsigned fileTicket { 1 };
|
unsigned fileTicket { 1 };
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,18 @@ void sfizz_force_garbage_collection(sfizz_synth_t* synth)
|
||||||
self->garbageCollect();
|
self->garbageCollect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sfizz_set_volume(sfizz_synth_t* synth, float volume)
|
||||||
|
{
|
||||||
|
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||||
|
self->setVolume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
float sfizz_get_volume(sfizz_synth_t* synth)
|
||||||
|
{
|
||||||
|
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||||
|
return self->getVolume();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -216,6 +216,22 @@ void sfizz_render_block(sfizz_synth_t* synth, float** channels, int num_channels
|
||||||
*/
|
*/
|
||||||
void sfizz_force_garbage_collection(sfizz_synth_t* synth);
|
void sfizz_force_garbage_collection(sfizz_synth_t* synth);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the global instrument volume.
|
||||||
|
*
|
||||||
|
* @param synth
|
||||||
|
* @param volume the new volume
|
||||||
|
*/
|
||||||
|
void sfizz_set_volume(sfizz_synth_t* synth, float volume);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the global instrument volume.
|
||||||
|
*
|
||||||
|
* @param synth
|
||||||
|
* @return float the instrument volume
|
||||||
|
*/
|
||||||
|
float sfizz_get_volume(sfizz_synth_t* synth);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Loading…
Add table
Reference in a new issue