本文整理汇总了C++中setVolume函数的典型用法代码示例。如果您正苦于以下问题:C++ setVolume函数的具体用法?C++ setVolume怎么用?C++ setVolume使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setVolume函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSrc
void
Movie::play() {
AC_INFO << "playing movie: "<< getSrc() << " (volume: " << _volume <<")";
masl::MovieEngineSingleton::get().getNative()->playMovie(this);
setVolume(_volume);
}
示例2: setVolume
void MusicNode::unsetPanTrack() {
_pantrack = false;
setVolume(_volume);
}
示例3: spk_setVolume
static void
spk_setVolume (volatile SpeechSynthesizer *spk, unsigned char setting) {
setVolume(getIntegerSpeechVolume(setting, 100));
}
示例4: switch
status_t BnMediaPlayer::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch(code) {
case DISCONNECT: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
disconnect();
return NO_ERROR;
} break;
case SET_VIDEO_SURFACE: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
sp<ISurface> surface = interface_cast<ISurface>(data.readStrongBinder());
reply->writeInt32(setVideoSurface(surface));
return NO_ERROR;
} break;
case PREPARE_ASYNC: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
reply->writeInt32(prepareAsync());
return NO_ERROR;
} break;
case START: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
reply->writeInt32(start());
return NO_ERROR;
} break;
case STOP: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
reply->writeInt32(stop());
return NO_ERROR;
} break;
case IS_PLAYING: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
bool state;
status_t ret = isPlaying(&state);
reply->writeInt32(state);
reply->writeInt32(ret);
return NO_ERROR;
} break;
case PAUSE: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
reply->writeInt32(pause());
return NO_ERROR;
} break;
case SEEK_TO: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
reply->writeInt32(seekTo(data.readInt32()));
return NO_ERROR;
} break;
case GET_CURRENT_POSITION: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
int msec;
status_t ret = getCurrentPosition(&msec);
reply->writeInt32(msec);
reply->writeInt32(ret);
return NO_ERROR;
} break;
case GET_DURATION: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
int msec;
status_t ret = getDuration(&msec);
reply->writeInt32(msec);
reply->writeInt32(ret);
return NO_ERROR;
} break;
case RESET: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
reply->writeInt32(reset());
return NO_ERROR;
} break;
case SET_AUDIO_STREAM_TYPE: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
reply->writeInt32(setAudioStreamType(data.readInt32()));
return NO_ERROR;
} break;
case SET_LOOPING: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
reply->writeInt32(setLooping(data.readInt32()));
return NO_ERROR;
} break;
case SET_VOLUME: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
reply->writeInt32(setVolume(data.readFloat(), data.readFloat()));
return NO_ERROR;
} break;
case INVOKE: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
invoke(data, reply);
return NO_ERROR;
} break;
case SET_METADATA_FILTER: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
reply->writeInt32(setMetadataFilter(data));
return NO_ERROR;
} break;
case SUSPEND: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
reply->writeInt32(suspend());
return NO_ERROR;
} break;
case RESUME: {
//.........这里部分代码省略.........
示例5: setVolume
bool BaseSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) {
return setVolume(type, percent * 255 / 100);
}
示例6: ALOGI
bool AudioDecoder::resample()
{
if (_result.sampleRate == _sampleRate)
{
ALOGI("No need to resample since the sample rate (%d) of the decoded pcm data is the same as the device output sample rate",
_sampleRate);
return true;
}
ALOGV("Resample: %d --> %d", _result.sampleRate, _sampleRate);
auto r = _result;
PcmBufferProvider provider;
provider.init(r.pcmBuffer->data(), r.numFrames, r.pcmBuffer->size() / r.numFrames);
const int outFrameRate = _sampleRate;
int outputChannels = 2;
size_t outputFrameSize = outputChannels * sizeof(int32_t);
size_t outputFrames = ((int64_t) r.numFrames * outFrameRate) / r.sampleRate;
size_t outputSize = outputFrames * outputFrameSize;
void *outputVAddr = malloc(outputSize);
auto resampler = AudioResampler::create(AUDIO_FORMAT_PCM_16_BIT, r.numChannels, outFrameRate,
AudioResampler::MED_QUALITY);
resampler->setSampleRate(r.sampleRate);
resampler->setVolume(AudioResampler::UNITY_GAIN_FLOAT, AudioResampler::UNITY_GAIN_FLOAT);
memset(outputVAddr, 0, outputSize);
ALOGV("resample() %zu output frames", outputFrames);
std::vector<int> Ovalues;
if (Ovalues.empty())
{
Ovalues.push_back(outputFrames);
}
for (size_t i = 0, j = 0; i < outputFrames;)
{
size_t thisFrames = Ovalues[j++];
if (j >= Ovalues.size())
{
j = 0;
}
if (thisFrames == 0 || thisFrames > outputFrames - i)
{
thisFrames = outputFrames - i;
}
int outFrames = resampler->resample((int *) outputVAddr + outputChannels * i, thisFrames,
&provider);
ALOGV("outFrames: %d", outFrames);
i += thisFrames;
}
ALOGV("resample() complete");
resampler->reset();
ALOGV("reset() complete");
delete resampler;
resampler = nullptr;
// mono takes left channel only (out of stereo output pair)
// stereo and multichannel preserve all channels.
int channels = r.numChannels;
int32_t *out = (int32_t *) outputVAddr;
int16_t *convert = (int16_t *) malloc(outputFrames * channels * sizeof(int16_t));
const int volumeShift = 12; // shift requirement for Q4.27 to Q.15
// round to half towards zero and saturate at int16 (non-dithered)
const int roundVal = (1 << (volumeShift - 1)) - 1; // volumePrecision > 0
for (size_t i = 0; i < outputFrames; i++)
{
for (int j = 0; j < channels; j++)
{
int32_t s = out[i * outputChannels + j] + roundVal; // add offset here
if (s < 0)
{
s = (s + 1) >> volumeShift; // round to 0
if (s < -32768)
{
s = -32768;
}
} else
{
s = s >> volumeShift;
if (s > 32767)
{
s = 32767;
}
}
convert[i * channels + j] = int16_t(s);
}
示例7: setFreq
SinOsc::SinOsc(float freq, float volume) {
phase = 0.0f;
setFreq(freq);
setVolume(volume);
}
示例8: hammerMain
void hammerMain() {
uprint("\r\n ######################## BOOT UP (HAMMER) ######################## \r\n");
initHammerState();
HammerState *hs = getHammerStatePtr();
configureAccelerometer();
configureAudio();
audioReset();
int sta = configureRadio(0x0A00, 0x0000111111111111);
uprint_int("Configured radio: ", sta);
configureIRReceive();
configureLightMCU_SPI();
updateLightMCUAll(hs->health, hs->charge);
char sendString[2] = "x";
char rxbuf[50];
char doneString[] = "DONE";
DELAY_MS(400);
playSound(HS_BOOT);
DELAY_MS(HS_BOOT_LEN);
while (1) {
uprint("Beginning of main loop");
hs->charge = 0;
updateLightMCUAll(hs->health, hs->charge);
uprint("Waiting for spin...");
startTrackingSpin();
while (!checkSpinComplete());
uprint("Spin complete!");
playSound(HS_SPINCOMPLETE);
DELAY_MS(HS_SPINCOMPLETE_LEN);
setVolume(5);
// Charging is really damn loud
// This sound is very long, we just start it playing
playSound(HS_CHARGING);
uprint("Charging ...");
hs->charge = 0;
hs->charging = 1;
while (hs->charge < 100) {
hs->charge ++;
updateLightMCUCharge(hs->charge);
DELAY_MS((0.9 * hs->health) + 10);
}
hs->charging = 0;
setVolume(8);
// Back to normal
playSound(HS_CHARGECOMPLETE);
DELAY_MS(HS_CHARGECOMPLETE_LEN);
uprint("Finished charging!");
uprint("Waiting for thrust...");
startTrackingThrust();
while (!checkThrustComplete());
setLightMCUHitAnim();
uprint("Thrust complete!");
playSound(HS_FIRE);
DELAY_MS(HS_FIRE_LEN);
setLightMCURainbow();
// Become invincible
disableIRReceive();
uprint("Sending radio message");
sendString[0] = hs->health;
radioSendMessage(sendString, 0x0A00);
uprint("Waiting for cloud message");
radioGetMessage(rxbuf, 50);
if (memcmp(rxbuf, doneString, 4) != 0) {
uprint("Invalid message from cloud!");
}
enableIRReceive();
uprint("Got cloud message");
setLightMCUOff();
//.........这里部分代码省略.........
示例9: if
bool UrlAudioPlayer::prepare(const std::string &url, SLuint32 locatorType, std::shared_ptr<AssetFd> assetFd, int start,
int length)
{
_url = url;
_assetFd = assetFd;
const char* locatorTypeStr= "UNKNOWN";
if (locatorType == SL_DATALOCATOR_ANDROIDFD)
locatorTypeStr = "SL_DATALOCATOR_ANDROIDFD";
else if (locatorType == SL_DATALOCATOR_URI)
locatorTypeStr = "SL_DATALOCATOR_URI";
else
{
ALOGE("Oops, invalid locatorType: %d", (int)locatorType);
return false;
}
ALOGV("UrlAudioPlayer::prepare: %s, %s, %d, %d, %d", _url.c_str(), locatorTypeStr, _assetFd->getFd(), start,
length);
SLDataSource audioSrc;
SLDataFormat_MIME formatMime = {SL_DATAFORMAT_MIME, nullptr, SL_CONTAINERTYPE_UNSPECIFIED};
audioSrc.pFormat = &formatMime;
//Note: locFd & locUri should be outside of the following if/else block
// Although locFd & locUri are only used inside if/else block, its lifecycle
// will be destroyed right after '}' block. And since we pass a pointer to
// 'audioSrc.pLocator=&locFd/&locUri', pLocator will point to an invalid address
// while invoking Engine::createAudioPlayer interface. So be care of change the position
// of these two variables.
SLDataLocator_AndroidFD locFd;
SLDataLocator_URI locUri;
if (locatorType == SL_DATALOCATOR_ANDROIDFD)
{
locFd = {locatorType, _assetFd->getFd(), start, length};
audioSrc.pLocator = &locFd;
}
else if (locatorType == SL_DATALOCATOR_URI)
{
locUri = {locatorType, (SLchar *) _url.c_str()};
audioSrc.pLocator = &locUri;
ALOGV("locUri: locatorType: %d", (int)locUri.locatorType);
}
// configure audio sink
SLDataLocator_OutputMix locOutmix = {SL_DATALOCATOR_OUTPUTMIX, _outputMixObj};
SLDataSink audioSnk = {&locOutmix, nullptr};
// create audio player
const SLInterfaceID ids[3] = {SL_IID_SEEK, SL_IID_PREFETCHSTATUS, SL_IID_VOLUME};
const SLboolean req[3] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
SLresult result = (*_engineItf)->CreateAudioPlayer(_engineItf, &_playObj, &audioSrc, &audioSnk,
3, ids, req);
SL_RETURN_VAL_IF_FAILED(result, false, "CreateAudioPlayer failed");
// realize the player
result = (*_playObj)->Realize(_playObj, SL_BOOLEAN_FALSE);
SL_RETURN_VAL_IF_FAILED(result, false, "Realize failed");
// get the play interface
result = (*_playObj)->GetInterface(_playObj, SL_IID_PLAY, &_playItf);
SL_RETURN_VAL_IF_FAILED(result, false, "GetInterface SL_IID_PLAY failed");
// get the seek interface
result = (*_playObj)->GetInterface(_playObj, SL_IID_SEEK, &_seekItf);
SL_RETURN_VAL_IF_FAILED(result, false, "GetInterface SL_IID_SEEK failed");
// get the volume interface
result = (*_playObj)->GetInterface(_playObj, SL_IID_VOLUME, &_volumeItf);
SL_RETURN_VAL_IF_FAILED(result, false, "GetInterface SL_IID_VOLUME failed");
result = (*_playItf)->RegisterCallback(_playItf,
SLUrlAudioPlayerCallbackProxy::playEventCallback, this);
SL_RETURN_VAL_IF_FAILED(result, false, "RegisterCallback failed");
result = (*_playItf)->SetCallbackEventsMask(_playItf, SL_PLAYEVENT_HEADATEND);
SL_RETURN_VAL_IF_FAILED(result, false, "SetCallbackEventsMask SL_PLAYEVENT_HEADATEND failed");
setState(State::INITIALIZED);
setVolume(1.0f);
return true;
}
示例10: volume
void EnginePhonon::volumeDec( )
{
int percent = volume() > 0 ? volume() -1 : 0;
setVolume(percent);
};
示例11: EngineBase
/*
********************************************************************************
* *
* Class EnginePhonon *
* *
********************************************************************************
*/
EnginePhonon::EnginePhonon() : EngineBase("phonon")
{
m_type = ENGINE::PHONON;
m_mediaObject = new Phonon::MediaObject(this);
m_audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
/* ----- by default tick every 1 second ----- */
m_mediaObject->setTickInterval(100);
Debug::debug() << "[EnginePhonon] -> tick Interval (actual): " << m_mediaObject->tickInterval();
/* ----- get the next track when there is 2 seconds left on the current one ----- */
/* in case of playing track from track view */
m_mediaObject->setPrefinishMark( 2000 );
m_mediaObject->setTransitionTime(100); /* GAPLESS/CROSSFADE */
connect(m_mediaObject,SIGNAL(finished()),this,SLOT(slot_on_media_finished()));
connect(m_mediaObject,SIGNAL(aboutToFinish()),this,SLOT(slot_on_media_about_to_finish()));
connect(m_mediaObject,SIGNAL(stateChanged(Phonon::State,Phonon::State)),this,SLOT(slot_on_phonon_state_changed(Phonon::State,Phonon::State)),Qt::DirectConnection);
connect(m_mediaObject,SIGNAL(tick(qint64)),this,SLOT(slot_on_time_change(qint64)));
connect(m_mediaObject,SIGNAL(totalTimeChanged(qint64)),this,SLOT(slot_on_duration_change(qint64)));
connect(m_mediaObject,SIGNAL(currentSourceChanged( const Phonon::MediaSource & )),this,SLOT(slot_on_media_change()));
connect(m_mediaObject, SIGNAL(metaDataChanged()), this,SLOT(slot_on_metadata_change()));
/* needed for Mplayer2 backend */
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ),this, SIGNAL( volumeChanged() ) );
connect( m_audioOutput, SIGNAL( mutedChanged( bool ) ), this, SIGNAL( muteStateChanged() ) );
m_phononPath = Phonon::createPath(m_mediaObject,m_audioOutput);
/* ----- only create pre-amp if we have replaygain on, VolumeFaderEffect can cause phonon issues */
m_preamp = 0;
if( SETTINGS()->_replaygain != SETTING::ReplayGainOff )
{
m_preamp = new Phonon::VolumeFaderEffect( this );
m_phononPath.insertEffect( m_preamp );
}
/* ----- add an equalizer effect if available */
m_equalizer = 0;
QList<Phonon::EffectDescription> mEffectDescriptions = Phonon::BackendCapabilities::availableAudioEffects();
foreach ( const Phonon::EffectDescription &mDescr, mEffectDescriptions )
{
if ( mDescr.name() == QLatin1String( "KEqualizer" ) )
{
m_equalizer = new Phonon::Effect( mDescr, this );
if( SETTINGS()->_enableEq ) {
addEqualizer();
loadEqualizerSettings();
}
}
}
/* ----- initial volume setup ----- */
setVolume( SETTINGS()->_volumeLevel );
m_current_state = ENGINE::STOPPED;
m_old_state = ENGINE::STOPPED;
m_version = QString();
}
示例12: setVolume
void RingControl::profileChanged()
{
QPhoneProfile prof = d->profileManager->activeProfile();
setVolume(prof.volume());
setMsgRingTime(prof.msgAlertDuration());
}
示例13: debugC
void MidiPlayer::adjustVolume(int diff) {
debugC(3, kDebugMusic, "MidiPlayer::adjustVolume");
setVolume(_masterVolume + diff);
}
示例14: setVolume
void MediaPlayer::decrementVolume()
{
setVolume(volume()-1);
}
示例15: setVolume
void AudioPlayerGnu::unmute()
{
if(_isMuted)
setVolume(volumeForMute);
_isMuted=false;
}