本文整理汇总了C++中MidiMessage::getMidiNoteInHertz方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiMessage::getMidiNoteInHertz方法的具体用法?C++ MidiMessage::getMidiNoteInHertz怎么用?C++ MidiMessage::getMidiNoteInHertz使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MidiMessage
的用法示例。
在下文中一共展示了MidiMessage::getMidiNoteInHertz方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processBlock
void LyrebirdAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
// Do Midi things
buffer.clear();
int time;
MidiMessage m;
for (MidiBuffer::Iterator i (midiMessages); i.getNextEvent (m, time);)
{
sawGenerator->setWavelength(currentSampleRate, m.getMidiNoteInHertz(m.getNoteNumber()));
if (m.isNoteOff())
{
sawGenerator->setWavelength(currentSampleRate, 0);
}
}
// In case we have more outputs than inputs, this code clears any output
// channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage).
// I've added this to avoid people getting screaming feedback
// when they first compile the plugin, but obviously you don't need to
// this code if your algorithm already fills all the output channels.
for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)
buffer.clear (i, 0, buffer.getNumSamples());
float* leftData = buffer.getWritePointer (0);
float* rightData = buffer.getWritePointer(1);
for (int sample = 0; sample < buffer.getNumSamples(); sample++)
{
leftData[sample] = sawGenerator->getCurrentAmplitude();
rightData[sample] = sawGenerator->getCurrentAmplitude();
sawGenerator->incrementSaw();
}
}
示例2: processBlock
void SynthAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
const int totalNumInputChannels = getTotalNumInputChannels();
const int totalNumOutputChannels = getTotalNumOutputChannels();
// In case we have more outputs than inputs, this code clears any output
// channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage).
// This is here to avoid people getting screaming feedback
// when they first compile a plugin, but obviously you don't need to keep
// this code if your algorithm always overwrites all the output channels.
MidiBuffer Midi;
int time;
MidiMessage m;
for(MidiBuffer::Iterator i(midiMessages); i.getNextEvent(m, time);){
//handle monophonic on/off of notes
if(m.isNoteOn()){
noteOn++;
}
if(m.isNoteOff()){
noteOn--;
}
if(noteOn > 0){
monoNoteOn = 1.0f;
env.reset();
//handle the pitch of the note
noteVal = m.getNoteNumber();
osc.setF(m.getMidiNoteInHertz(noteVal));
}else{
monoNoteOn = 0.0f;
}
}
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
for (int channel = 0; channel < totalNumOutputChannels; ++channel){
//just do the synth stuff on one channel.
if(channel == 0){
for(int sample = 0; sample < buffer.getNumSamples(); ++sample){
//do this stuff here. it's terribly inefficient..
freqValScaled = 20000.0f * pow(freqP->get(), 3.0f);
envValScaled = 10000.0f * pow(envP->get(), 3.0f);
speedValScaled = pow((1.0f - speedP->get()), 2.0f);
oscValScaled = (oscP->get() - 0.5f) * 70.0f;
detValScaled = (detP->get() - 0.5f) * 24.0f;
filter.setFc(freqSmoothing.process(freqValScaled + (envValScaled * pow(env.process(),3.0f))) / UPSAMPLING);
env.setSpeed(speedValScaled);
filter.setQ(qP->get());
float frequency = noteVal + 24.0f + oscValScaled + modOsc.process(0) + (driftSmoothing.process(random.nextFloat() - 0.5f) * 20.0f);
float frequency2 = exp((frequency + detValScaled + (driftSmoothing2.process(random.nextFloat() - 0.5f) * 10.0f)) / 17.31f) / UPSAMPLING;
frequency = exp(frequency / 17.31f) / UPSAMPLING;
osc.setF(frequency);
osc2.setF(frequency2);
float monoNoteOn2 = ampSmoothing.process(monoNoteOn);
float data;
for(int i = 0; i < UPSAMPLING; i++){
data = 20.0f * filter.process(0.1f * osc.process() + ampP->get() * 0.1f * osc2.process());
}
data *= monoNoteOn2;
buffer.setSample(0, sample, data);
buffer.setSample(1, sample, data);
}
}
}
}