Пример #1
0
void ModulatorSamplerSound::setPropertyInternal(Property p, int newValue)
{
	switch (p)
	{
	case ID:			jassertfalse; break;
	case FileName:		jassertfalse; break;
	case RootNote:		rootNote = newValue; break;
	case VeloHigh: {	int low = jmin(velocityRange.findNextSetBit(0), newValue, 127);
		velocityRange.clear();
		velocityRange.setRange(low, newValue - low + 1, true); break; }
	case VeloLow: {	int high = jmax(velocityRange.getHighestBit(), newValue, 0);
		velocityRange.clear();
		velocityRange.setRange(newValue, high - newValue + 1, true); break; }
	case KeyHigh: {	int low = jmin(midiNotes.findNextSetBit(0), newValue, 127);
		midiNotes.clear();
		midiNotes.setRange(low, newValue - low + 1, true); break; }
	case KeyLow: {	int high = jmax(midiNotes.getHighestBit(), newValue, 0);
		midiNotes.clear();
		midiNotes.setRange(newValue, high - newValue + 1, true); break; }
	case RRGroup:		rrGroup = newValue; break;
	case Normalized:	isNormalized = newValue == 1;
		if (isNormalized && normalizedPeak < 0.0f) calculateNormalizedPeak();
		break;
	case Volume: {	gain.set(Decibels::decibelsToGain((float)newValue));
		break;
	}
	case Pan: {
		pan = (int)newValue;
		leftBalanceGain = BalanceCalculator::getGainFactorForBalance((float)newValue, true);
		rightBalanceGain = BalanceCalculator::getGainFactorForBalance((float)newValue, false);
		break;
	}
	case Pitch: {	centPitch = newValue;
		pitchFactor.store(powf(2.0f, (float)centPitch / 1200.f));
		break;
	};
	case SampleStart:	FOR_EVERY_SOUND(setSampleStart(newValue)); break;
	case SampleEnd:		FOR_EVERY_SOUND(setSampleEnd(newValue)); break;
	case SampleStartMod: FOR_EVERY_SOUND(setSampleStartModulation(newValue)); break;

	case LoopEnabled:	FOR_EVERY_SOUND(setLoopEnabled(newValue == 1.0f)); break;
	case LoopStart:		FOR_EVERY_SOUND(setLoopStart(newValue)); break;
	case LoopEnd:		FOR_EVERY_SOUND(setLoopEnd(newValue)); break;
	case LoopXFade:		FOR_EVERY_SOUND(setLoopCrossfade(newValue)); break;
	case LowerVelocityXFade: lowerVeloXFadeValue = newValue; break;
	case UpperVelocityXFade: upperVeloXFadeValue = newValue; break;
	case SampleState:	setPurged(newValue == 1.0f); break;
	default:			jassertfalse; break;
	}

}
Пример #2
0
void GameAudioImpl::playSE(const StringRef& filePath, float volume, float pitch)
{
    auto sound = createSound(filePath);

    // ボリューム・ピッチ設定
    sound->setVolume(volume);
    sound->setPitch(pitch);

    // 再生途中で解放されようとしても再生終了までは解放されない & SE として再生する
    sound->setGameAudioFlags(GameAudioFlags_SE);
    pushReleaseAtPlayEndList(sound);

    // 再生
    sound->setLoopEnabled(false);
    sound->play();
}
Пример #3
0
void GameAudioImpl::playSE3D(const StringRef& filePath, const Vector3& position, float distance, float volume, float pitch)
{
    // サウンド作成
    auto sound = createSound(filePath);
    sound->set3DEnabled(true);

    // 位置・ピッチ設定
    sound->setEmitterPosition(position);
    sound->setEmitterMaxDistance(distance);
    sound->setVolume(volume);
    sound->setPitch(pitch);

    // 再生途中で解放されようとしても再生終了までは解放されない & SE として再生する
    sound->setGameAudioFlags(GameAudioFlags_SE);
    pushReleaseAtPlayEndList(sound);

    // 再生
    sound->setLoopEnabled(false);
    sound->play();
}