本文整理汇总了C++中sampleRate函数的典型用法代码示例。如果您正苦于以下问题:C++ sampleRate函数的具体用法?C++ sampleRate怎么用?C++ sampleRate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sampleRate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ASSERT
PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(MediaStream* mediaStream, ExceptionState& es)
{
ASSERT(mediaStream);
if (!mediaStream) {
es.throwDOMException(InvalidStateError);
return 0;
}
ASSERT(isMainThread());
lazyInitialize();
AudioSourceProvider* provider = 0;
MediaStreamTrackVector audioTracks = mediaStream->getAudioTracks();
// FIXME: get a provider for non-local MediaStreams (like from a remote peer).
for (size_t i = 0; i < audioTracks.size(); ++i) {
RefPtr<MediaStreamTrack> localAudio = audioTracks[i];
if (localAudio->component()->audioSourceProvider()) {
provider = localAudio->component()->audioSourceProvider();
break;
}
}
RefPtr<MediaStreamAudioSourceNode> node = MediaStreamAudioSourceNode::create(this, mediaStream, provider);
// FIXME: Only stereo streams are supported right now. We should be able to accept multi-channel streams.
node->setFormat(2, sampleRate());
refNode(node.get()); // context keeps reference until node is disconnected
return node;
}
开发者ID:huningxin,项目名称:blink-crosswalk,代码行数:32,代码来源:AudioContext.cpp
示例2: sizeof
void Minim::Delay::channelCountChanged()
{
if ( delayBuffer )
{
delete[] delayBuffer;
delayBuffer = NULL;
}
if ( sampleRate() > 0 )
{
maxBufferSize = (int)( maxDelayTime*sampleRate()*getAudioChannelCount() );
delayBuffer = new float[maxBufferSize];
memset(delayBuffer, 0, sizeof(float)*maxBufferSize);
bufferSizeChanged();
}
}
开发者ID:EQ4,项目名称:minim-cpp,代码行数:16,代码来源:Delay.cpp
示例3: usleep
ssize_t AudioStreamInStub::read(void* buffer, ssize_t bytes)
{
// fake timing for audio input
usleep(bytes * 1000000 / sizeof(int16_t) / AudioSystem::popCount(channels()) / sampleRate());
memset(buffer, 0, bytes);
return bytes;
}
开发者ID:bq-rk3066,项目名称:android_device_bq_maxwell2lite_DEPRECATED,代码行数:7,代码来源:AudioHardwareStub.cpp
示例4: snprintf
status_t AudioStreamInMotorola::dump(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
String8 result;
result.append("AudioStreamInMotorola::dump\n");
snprintf(buffer, SIZE, "\tsample rate: %d\n", sampleRate());
result.append(buffer);
snprintf(buffer, SIZE, "\tbuffer size: %d\n", bufferSize());
result.append(buffer);
snprintf(buffer, SIZE, "\tchannels: %d\n", channels());
result.append(buffer);
snprintf(buffer, SIZE, "\tformat: %d\n", format());
result.append(buffer);
snprintf(buffer, SIZE, "\tmHardware: %p\n", mHardware);
result.append(buffer);
snprintf(buffer, SIZE, "\tmFd count: %d\n", mFd);
result.append(buffer);
snprintf(buffer, SIZE, "\tmStandby: %d\n", mStandby);
result.append(buffer);
snprintf(buffer, SIZE, "\tmRetryCount: %d\n", mRetryCount);
result.append(buffer);
::write(fd, result.string(), result.size());
return NO_ERROR;
}
开发者ID:Aaahh,项目名称:shadow-cm11.0,代码行数:25,代码来源:AudioStreamInMotorola.cpp
示例5: buffer
double AudioBufferSourceNode::totalPitchRate()
{
double dopplerRate = 1.0;
if (m_pannerNode)
dopplerRate = m_pannerNode->dopplerRate();
// Incorporate buffer's sample-rate versus AudioContext's sample-rate.
// Normally it's not an issue because buffers are loaded at the AudioContext's sample-rate, but we can handle it in any case.
double sampleRateFactor = 1.0;
if (buffer())
sampleRateFactor = buffer()->sampleRate() / sampleRate();
double basePitchRate = playbackRate()->value();
double totalRate = dopplerRate * sampleRateFactor * basePitchRate;
totalRate = std::max(-MaxRate, std::min(MaxRate, totalRate));
bool isTotalRateValid = !std::isnan(totalRate) && !std::isinf(totalRate);
ASSERT(isTotalRateValid);
if (!isTotalRateValid)
totalRate = 1.0;
return totalRate;
}
开发者ID:fanghongjia,项目名称:JavaScriptCore,代码行数:25,代码来源:AudioBufferSourceNode.cpp
示例6: buffer
double AudioBufferSourceNode::totalPitchRate()
{
double dopplerRate = 1.0;
if (m_pannerNode)
dopplerRate = m_pannerNode->dopplerRate();
// Incorporate buffer's sample-rate versus AudioContext's sample-rate.
// Normally it's not an issue because buffers are loaded at the AudioContext's sample-rate, but we can handle it in any case.
double sampleRateFactor = 1.0;
if (buffer())
sampleRateFactor = buffer()->sampleRate() / sampleRate();
double basePitchRate = playbackRate()->value();
double totalRate = dopplerRate * sampleRateFactor * basePitchRate;
// Sanity check the total rate. It's very important that the resampler not get any bad rate values.
totalRate = std::max(0.0, totalRate);
if (!totalRate)
totalRate = 1; // zero rate is considered illegal
totalRate = std::min(MaxRate, totalRate);
bool isTotalRateValid = !std::isnan(totalRate) && !std::isinf(totalRate);
ASSERT(isTotalRateValid);
if (!isTotalRateValid)
totalRate = 1.0;
return totalRate;
}
开发者ID:kjthegod,项目名称:WebKit,代码行数:29,代码来源:AudioBufferSourceNode.cpp
示例7: setFormat
void MediaStreamAudioSourceNode::setFormat(size_t numberOfChannels, float sourceSampleRate)
{
if (numberOfChannels != m_sourceNumberOfChannels || sourceSampleRate != sampleRate()) {
// The sample-rate must be equal to the context's sample-rate.
if (!numberOfChannels || numberOfChannels > AudioContext::maxNumberOfChannels() || sourceSampleRate != sampleRate()) {
// process() will generate silence for these uninitialized values.
LOG(Media, "MediaStreamAudioSourceNode::setFormat(%u, %f) - unhandled format change", static_cast<unsigned>(numberOfChannels), sourceSampleRate);
m_sourceNumberOfChannels = 0;
return;
}
// Synchronize with process().
MutexLocker locker(m_processLock);
m_sourceNumberOfChannels = numberOfChannels;
{
// The context must be locked when changing the number of output channels.
AudioContext::AutoLocker contextLocker(context());
// Do any necesssary re-configuration to the output's number of channels.
output(0)->setNumberOfChannels(numberOfChannels);
}
}
}
开发者ID:ZECTBynmo,项目名称:LabSound,代码行数:25,代码来源:MediaStreamAudioSourceNode.cpp
示例8: sampleRate
void Minim::MoogFilter::uGenerate( float * out, const int numChannels )
{
// Set coefficients given frequency & resonance [0.0...1.0]
float t1, t2; // temporary buffers
float normFreq = frequency.getLastValue() / ( sampleRate() * 0.5f );
float rez = constrain( resonance.getLastValue(), 0.f, 1.f );
float q = 1.0f - normFreq;
float p = normFreq + 0.8f * normFreq * q;
float f = p + p - 1.0f;
q = rez * ( 1.0f + 0.5f * q * ( 1.0f - q + 5.6f * q * q ) );
const float* input = audio.getLastValues();
for ( int i = 0; i < numChannels; ++i )
{
// Filter (in [-1.0...+1.0])
float* b = coeff[i];
float in = constrain( input[i], -1, 1 ); // hard clip
//float in = atanf(input[i]) * M_2_PI; // soft clip
in -= q * b[4]; // feedback
t1 = b[1];
b[1] = ( in + b[0] ) * p - b[1] * f;
t2 = b[2];
b[2] = ( b[1] + t1 ) * p - b[2] * f;
t1 = b[3];
b[3] = ( b[2] + t2 ) * p - b[3] * f;
b[4] = ( b[3] + t1 ) * p - b[4] * f;
b[4] = b[4] - b[4] * b[4] * b[4] * 0.166667f; // clipping
// inelegantly squash denormals
if ( isnan(b[4]) )
{
memset(b, 0, sizeof(float)*5);
}
b[0] = in;
switch( type )
{
case HP:
out[i] = in - b[4];
break;
case LP:
out[i] = b[4];
break;
case BP:
out[i] = 3.0f * (b[3] - b[4]);
break;
}
}
}
开发者ID:EQ4,项目名称:minim-cpp,代码行数:59,代码来源:MoogFilter.cpp
示例9: bytesForDuration
/*!
Returns the number of microseconds represented by \a bytes in this format.
Returns 0 if this format is not valid->
Note that some rounding may occur if \a bytes is not an exact multiple
of the number of bytes per frame.
\sa bytesForDuration()
*/
qint64 AudioFormat::durationForBytes(qint32 bytes) const
{
if (!isValid() || bytes <= 0)
return 0;
// We round the byte count to ensure whole frames
return qint64(kHz * (bytes / bytesPerFrame())) / sampleRate();
}
开发者ID:DavidJohnSmith,项目名称:QtAV,代码行数:18,代码来源:AudioFormat.cpp
示例10: negativeRatesError
void ADSREnvOld::setReleaseTime( FLOAT time )
{
if( time < 0.0 ) {
negativeRatesError();
time *= -1;
}
releaseRate_ = sustainLevel_ / ( time * sampleRate() );
}
开发者ID:dreieier,项目名称:Nexus,代码行数:8,代码来源:ADSREnvOld.cpp
示例11: wrapUnique
void DynamicsCompressorHandler::initialize()
{
if (isInitialized())
return;
AudioHandler::initialize();
m_dynamicsCompressor = wrapUnique(new DynamicsCompressor(sampleRate(), defaultNumberOfOutputChannels));
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:8,代码来源:DynamicsCompressorNode.cpp
示例12: sampleRate
void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassRefPtr<AudioBufferCallback> successCallback, PassRefPtr<AudioBufferCallback> errorCallback, ExceptionState& es)
{
if (!audioData) {
es.throwDOMException(SyntaxError);
return;
}
m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCallback);
}
开发者ID:huningxin,项目名称:blink-crosswalk,代码行数:8,代码来源:AudioContext.cpp
示例13: tailTime
double HRTFPanner::tailTime() const {
// Because HRTFPanner is implemented with a DelayKernel and a FFTConvolver,
// the tailTime of the HRTFPanner is the sum of the tailTime of the
// DelayKernel and the tailTime of the FFTConvolver, which is
// MaxDelayTimeSeconds and fftSize() / 2, respectively.
return MaxDelayTimeSeconds +
(fftSize() / 2) / static_cast<double>(sampleRate());
}
开发者ID:mirror,项目名称:chromium,代码行数:8,代码来源:HRTFPanner.cpp
示例14: sampleRate
void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassRefPtr<AudioBufferCallback> successCallback, PassRefPtr<AudioBufferCallback> errorCallback, ExceptionCode& ec)
{
if (!audioData) {
ec = SYNTAX_ERR;
return;
}
m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCallback);
}
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:8,代码来源:AudioContext.cpp
示例15: usleep
ssize_t AudioStreamInStub::read(void* buffer, ssize_t bytes)
{
// fake timing for audio input
usleep(bytes * 1000000 / sizeof(int16_t) /
audio_channel_count_from_in_mask(channels()) / sampleRate());
memset(buffer, 0, bytes);
return bytes;
}
开发者ID:AOSP-JF,项目名称:platform_hardware_libhardware_legacy,代码行数:8,代码来源:AudioHardwareStub.cpp
示例16: set
status_t AudioStreamOutStub::set(int *pFormat, uint32_t *pChannels, uint32_t *pRate)
{
if (pFormat) *pFormat = format();
if (pChannels) *pChannels = channels();
if (pRate) *pRate = sampleRate();
return NO_ERROR;
}
开发者ID:AOSP-JF,项目名称:platform_hardware_libhardware_legacy,代码行数:8,代码来源:AudioHardwareStub.cpp
示例17: initialize
void StereoPannerHandler::initialize() {
if (isInitialized())
return;
m_stereoPanner = StereoPanner::create(sampleRate());
AudioHandler::initialize();
}
开发者ID:mirror,项目名称:chromium,代码行数:8,代码来源:StereoPannerNode.cpp
示例18: sampleRate
void StereoPannerHandler::initialize()
{
if (isInitialized())
return;
m_stereoPanner = Spatializer::create(Spatializer::PanningModelEqualPower, sampleRate());
AudioHandler::initialize();
}
开发者ID:howardroark2018,项目名称:chromium,代码行数:9,代码来源:StereoPannerNode.cpp
示例19: tryLocker
double ConvolverNode::latencyTime() const
{
MutexTryLocker tryLocker(m_processLock);
if (tryLocker.locked())
return m_reverb ? m_reverb->latencyFrames() / static_cast<double>(sampleRate()) : 0;
// Since we don't want to block the Audio Device thread, we return a large value
// instead of trying to acquire the lock.
return std::numeric_limits<double>::infinity();
}
开发者ID:darktears,项目名称:blink-crosswalk,代码行数:9,代码来源:ConvolverNode.cpp
示例20: LOGD
status_t A2dpAudioInterface::A2dpAudioStreamOut::set(
int format, int channels, uint32_t rate)
{
LOGD("A2dpAudioStreamOut::set %d, %d, %d\n", format, channels, rate);
// fix up defaults
if (format == 0) format = AudioSystem::PCM_16_BIT;
if (channels == 0) channels = channelCount();
if (rate == 0) rate = sampleRate();
// check values
if ((format != AudioSystem::PCM_16_BIT) ||
(channels != channelCount()) ||
(rate != sampleRate()))
return BAD_VALUE;
return NO_ERROR;
}
开发者ID:embest-tech,项目名称:rowboat-frameworks-base,代码行数:18,代码来源:A2dpAudioInterface.cpp
注:本文中的sampleRate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论