本文整理汇总了C++中setSampleRate函数的典型用法代码示例。如果您正苦于以下问题:C++ setSampleRate函数的具体用法?C++ setSampleRate怎么用?C++ setSampleRate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setSampleRate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setSampleRate
void AudioOss::applyQualitySettings()
{
if( hqAudio() )
{
setSampleRate( Engine::mixer()->processingSampleRate() );
unsigned int value = sampleRate();
if ( ioctl( m_audioFD, SNDCTL_DSP_SPEED, &value ) < 0 )
{
perror( "SNDCTL_DSP_SPEED" );
printf( "Couldn't set audio frequency\n" );
return;
}
if( value != sampleRate() )
{
value = mixer()->baseSampleRate();
if ( ioctl( m_audioFD, SNDCTL_DSP_SPEED, &value ) < 0 )
{
perror( "SNDCTL_DSP_SPEED" );
printf( "Couldn't set audio frequency\n" );
return;
}
setSampleRate( value );
}
}
AudioDevice::applyQualitySettings();
}
示例2: fopen
bool FileInputDataSource::open()
{
if (!mFp) {
unsigned int channel;
unsigned int sampleRate;
audio_format_type_t pcmFormat;
audio_type_t audioType;
mFp = fopen(mDataPath.c_str(), "rb");
if (!mFp) {
medvdbg("file open failed error : %d\n", errno);
return false;
}
audioType = utils::getAudioTypeFromPath(mDataPath);
setAudioType(audioType);
switch (audioType) {
case AUDIO_TYPE_MP3:
case AUDIO_TYPE_AAC:
if (!utils::header_parsing(mFp, audioType, &channel, &sampleRate, NULL)) {
medvdbg("header parsing failed\n");
return false;
}
setSampleRate(sampleRate);
setChannels(channel);
break;
case AUDIO_TYPE_WAVE:
if (!utils::header_parsing(mFp, audioType, &channel, &sampleRate, &pcmFormat)) {
medvdbg("header parsing failed\n");
return false;
}
if (fseek(mFp, WAVE_HEADER_LENGTH, SEEK_SET) != 0) {
medvdbg("file seek failed error\n");
return false;
}
setSampleRate(sampleRate);
setChannels(channel);
setPcmFormat(pcmFormat);
break;
case AUDIO_TYPE_FLAC:
/* To be supported */
break;
default:
/* Don't set any decoder for unsupported formats */
break;
}
return true;
}
/** return true if mFp is not null, because it means it using now */
return true;
}
示例3: switch
void GladiatorIMU::handleCommand(gladiator_cmd_t* cmd)
{
uint8_t* payload;
switch (cmd->command)
{
case CMD_LOADK:
printf("GladiatorIMU: Loading filter K: %f\n", *((float*)&cmd->payload));
loadFilterK(*((float*)&cmd->payload));
break;
case CMD_SETRATE:
printf("GladiatorIMU: Setting rate %dHz\n", cmd->payload);
switch (cmd->payload)
{
case 100:
setSampleRate(MODE_IMU_100HZ);
break;
case 200:
setSampleRate(MODE_IMU_200HZ);
break;
case 500:
setSampleRate(MODE_IMU_500HZ);
break;
case 1000:
setSampleRate(MODE_IMU_1000HZ);
break;
}
break;
case CMD_GETBOARD:
printf("GladiatorIMU: Returning board number bytes\n");
cmd->payload = 0;
payload = (uint8_t*)&(cmd->payload);
payload[0] = boardNumber[0];
payload[1] = boardNumber[1];
payload[2] = boardNumber[2];
payload[3] = boardNumber[3];
break;
case CMD_GETSTATUS:
printf("GladiatorIMU: Returning status bytes\n");
cmd->payload = 0;
payload = (uint8_t*)&(cmd->payload);
payload[0] = statusByte[0];
payload[1] = statusByte[1];
payload[2] = filterNumber;
payload[3] = 0;
break;
default:
printf("GladiatorIMU: Unknown command: 0x%d\n", cmd->command);
break;
}
cmd->signal();
}
示例4: setSampleRate
void AudioJack::applyQualitySettings()
{
if( hqAudio() )
{
setSampleRate( engine::mixer()->processingSampleRate() );
if( jack_get_sample_rate( m_client ) != sampleRate() )
{
setSampleRate( jack_get_sample_rate( m_client ) );
}
}
AudioDevice::applyQualitySettings();
}
示例5: DataUiHandlerProperty
GenericTimeDataParams::GenericTimeDataParams(DataUiHandlerProperty * baseProperty, TimePlotParams* params, QObject *parent ) :
DataUiHandlerProperty(baseProperty,parent),
m_startTime(0),
m_name(QString("no name")),
m_curveEnabled(true)
{
if (params) {
setSampleRate(params->sampleRate());
setMaxDuration(params->maxDuration());
} else {
setSampleRate(TIMEDATA_DEFAULT_SR);
setMaxDuration(TIMEDATA_DEFAULT_PROJECT_TIME);
}
}
示例6: sf_wchar_open
Result SoundSourceSndFile::open() {
#ifdef __WINDOWS__
// Pointer valid until string changed
LPCWSTR lpcwFilename = (LPCWSTR)getFilename().utf16();
fh = sf_wchar_open(lpcwFilename, SFM_READ, &info);
#else
const QByteArray qbaFilename(getFilename().toLocal8Bit());
fh = sf_open(qbaFilename.constData(), SFM_READ, &info);
#endif
if (fh == NULL) { // sf_format_check is only for writes
qWarning() << "libsndfile: Error opening file" << getFilename() << sf_strerror(fh);
return ERR;
}
if (sf_error(fh)>0) {
qWarning() << "libsndfile: Error opening file" << getFilename() << sf_strerror(fh);
return ERR;
}
channels = info.channels;
setSampleRate(info.samplerate);
// This is the 'virtual' filelength. No matter how many channels the file
// actually has, we pretend it has 2.
filelength = info.frames * 2; // File length with two interleaved channels
return OK;
}
示例7: AudioDevice
AudioFileDevice::AudioFileDevice( OutputSettings const & outputSettings,
const ch_cnt_t _channels,
const QString & _file,
Mixer* _mixer ) :
AudioDevice( _channels, _mixer ),
m_outputFile( _file ),
m_outputSettings(outputSettings)
{
setSampleRate( outputSettings.getSampleRate() );
if( m_outputFile.open( QFile::WriteOnly | QFile::Truncate ) == false )
{
QString title, message;
title = ExportProjectDialog::tr( "Could not open file" );
message = ExportProjectDialog::tr( "Could not open file %1 "
"for writing.\nPlease make "
"sure you have write "
"permission to the file and "
"the directory containing the "
"file and try again!"
).arg( _file );
if( gui )
{
QMessageBox::critical( NULL, title, message,
QMessageBox::Ok,
QMessageBox::NoButton );
}
else
{
fprintf( stderr, "%s\n", message.toUtf8().constData() );
exit( EXIT_FAILURE );
}
}
}
示例8: initAccelTable
void MMA7660::init()
{
initAccelTable();
setMode(MMA7660_STAND_BY);
setSampleRate(AUTO_SLEEP_32);
setMode(MMA7660_ACTIVE);
}
示例9: setWindowTitle
MainWindow::MainWindow()
{
setWindowTitle(tr("inspectrum"));
dock = new SpectrogramControls(tr("Controls"), this);
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
addDockWidget(Qt::LeftDockWidgetArea, dock);
input = new InputSource();
plots = new PlotView(input);
setCentralWidget(plots);
// Connect dock inputs
connect(dock, SIGNAL(openFile(QString)), this, SLOT(openFile(QString)));
connect(dock->sampleRate, SIGNAL(textChanged(QString)), this, SLOT(setSampleRate(QString)));
connect(dock, SIGNAL(fftOrZoomChanged(int, int)), plots, SLOT(setFFTAndZoom(int, int)));
connect(dock->powerMaxSlider, SIGNAL(valueChanged(int)), plots, SLOT(setPowerMax(int)));
connect(dock->powerMinSlider, SIGNAL(valueChanged(int)), plots, SLOT(setPowerMin(int)));
connect(dock->cursorsCheckBox, &QCheckBox::stateChanged, plots, &PlotView::enableCursors);
connect(dock->cursorBitsSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), plots, &PlotView::setCursorBits);
// Connect dock outputs
connect(plots, SIGNAL(timeSelectionChanged(float)), dock, SLOT(timeSelectionChanged(float)));
connect(plots, SIGNAL(zoomIn()), dock, SLOT(zoomIn()));
connect(plots, SIGNAL(zoomOut()), dock, SLOT(zoomOut()));
// Set defaults after making connections so everything is in sync
dock->setDefaults();
}
示例10: shared_from_this
void Device::updateFormat( const Format &format )
{
size_t sampleRate = format.getSampleRate();
size_t framesPerBlock = format.getFramesPerBlock();
if( mSampleRate == sampleRate && mFramesPerBlock == framesPerBlock )
return;
auto deviceMgr = Context::deviceManager();
mSignalParamsWillChange.emit();
if( sampleRate && sampleRate != mSampleRate ) {
// set the samplerate to 0, forcing it to refresh on next get.
mSampleRate = 0;
deviceMgr->setSampleRate( shared_from_this(), sampleRate );
}
if( framesPerBlock && framesPerBlock != mFramesPerBlock ) {
// set the frames per block to 0, forcing it to refresh on next get
mFramesPerBlock = 0;
deviceMgr->setFramesPerBlock( shared_from_this(), framesPerBlock );
}
if( ! deviceMgr->isFormatUpdatedAsync() )
mSignalParamsDidChange.emit();
}
示例11: setSampleRate
void AudioPortAudio::applyQualitySettings()
{
if( hqAudio() )
{
setSampleRate( Engine::mixer()->processingSampleRate() );
int samples = mixer()->framesPerPeriod();
PaError err = Pa_OpenStream(
&m_paStream,
supportsCapture() ? &m_inputParameters : NULL, // The input parameter
&m_outputParameters, // The outputparameter
sampleRate(),
samples,
paNoFlag, // Don't use any flags
_process_callback, // our callback function
this );
if( err != paNoError )
{
printf( "Couldn't open PortAudio: %s\n", Pa_GetErrorText( err ) );
return;
}
}
AudioDevice::applyQualitySettings();
}
示例12: qDebug
void TrackInfoObject::parse() {
// Log parsing of header information in developer mode. This is useful for
// tracking down corrupt files.
const QString& canonicalLocation = m_fileInfo.canonicalFilePath();
if (CmdlineArgs::Instance().getDeveloper()) {
qDebug() << "TrackInfoObject::parse()" << canonicalLocation;
}
// Parse the information stored in the sound file.
SoundSourceProxy proxy(canonicalLocation, m_pSecurityToken);
Mixxx::SoundSource* pProxiedSoundSource = proxy.getProxiedSoundSource();
if (pProxiedSoundSource != NULL && proxy.parseHeader() == OK) {
// Dump the metadata extracted from the file into the track.
// TODO(XXX): This involves locking the mutex for every setXXX
// method. We should figure out an optimization where there are private
// setters that don't lock the mutex.
// If Artist, Title and Type fields are not blank, modify them.
// Otherwise, keep their current values.
// TODO(rryan): Should we re-visit this decision?
if (!(pProxiedSoundSource->getArtist().isEmpty())) {
setArtist(pProxiedSoundSource->getArtist());
}
if (!(pProxiedSoundSource->getTitle().isEmpty())) {
setTitle(pProxiedSoundSource->getTitle());
}
if (!(pProxiedSoundSource->getType().isEmpty())) {
setType(pProxiedSoundSource->getType());
}
setAlbum(pProxiedSoundSource->getAlbum());
setAlbumArtist(pProxiedSoundSource->getAlbumArtist());
setYear(pProxiedSoundSource->getYear());
setGenre(pProxiedSoundSource->getGenre());
setComposer(pProxiedSoundSource->getComposer());
setGrouping(pProxiedSoundSource->getGrouping());
setComment(pProxiedSoundSource->getComment());
setTrackNumber(pProxiedSoundSource->getTrackNumber());
setReplayGain(pProxiedSoundSource->getReplayGain());
setBpm(pProxiedSoundSource->getBPM());
setDuration(pProxiedSoundSource->getDuration());
setBitrate(pProxiedSoundSource->getBitrate());
setSampleRate(pProxiedSoundSource->getSampleRate());
setChannels(pProxiedSoundSource->getChannels());
setKeyText(pProxiedSoundSource->getKey(),
mixxx::track::io::key::FILE_METADATA);
setHeaderParsed(true);
} else {
qDebug() << "TrackInfoObject::parse() error at file"
<< canonicalLocation;
setHeaderParsed(false);
// Add basic information derived from the filename:
parseFilename();
}
}
示例13: state
LadderFilter<Type>::LadderFilter() : state (2)
{
setSampleRate (Type (1000)); // intentionally setting unrealistic default
// sample rate to catch missing initialisation bugs
setResonance (Type (0));
setDrive (Type (1.2));
setMode (Mode::LPF12);
}
示例14: DEBUG_ASSERT
SoundSource::OpenResult SoundSourceWV::tryOpen(
OpenMode /*mode*/,
const OpenParams& params) {
DEBUG_ASSERT(!m_wpc);
char msg[80]; // hold possible error message
int openFlags = OPEN_WVC | OPEN_NORMALIZE;
if ((params.channelCount() == 1) ||
(params.channelCount() == 2)) {
openFlags |= OPEN_2CH_MAX;
}
// We use WavpackOpenFileInputEx to support Unicode paths on windows
// http://www.wavpack.com/lib_use.txt
QString wavPackFileName = getLocalFileName();
m_pWVFile = new QFile(wavPackFileName);
m_pWVFile->open(QFile::ReadOnly);
QString correctionFileName(wavPackFileName + "c");
if (QFile::exists(correctionFileName)) {
// If there is a correction file, open it as well
m_pWVCFile = new QFile(correctionFileName);
m_pWVCFile->open(QFile::ReadOnly);
}
m_wpc = WavpackOpenFileInputEx(&s_streamReader, m_pWVFile, m_pWVCFile,
msg, openFlags, 0);
if (!m_wpc) {
kLogger.warning() << "failed to open file : " << msg;
return OpenResult::Failed;
}
setChannelCount(WavpackGetReducedChannels(m_wpc));
setSampleRate(WavpackGetSampleRate(m_wpc));
initFrameIndexRangeOnce(
mixxx::IndexRange::forward(
0,
WavpackGetNumSamples(m_wpc)));
if (WavpackGetMode(m_wpc) & MODE_FLOAT) {
m_sampleScaleFactor = CSAMPLE_PEAK;
} else {
const int bitsPerSample = WavpackGetBitsPerSample(m_wpc);
if ((bitsPerSample >= 8) && (bitsPerSample <= 32)) {
// Range of signed sample values: [-2 ^ (bitsPerSample - 1), 2 ^ (bitsPerSample - 1) - 1]
const uint32_t absSamplePeak = 1u << (bitsPerSample - 1);
DEBUG_ASSERT(absSamplePeak > 0);
// Scaled range of sample values: [-CSAMPLE_PEAK, CSAMPLE_PEAK)
m_sampleScaleFactor = CSAMPLE_PEAK / absSamplePeak;
} else {
kLogger.warning()
<< "Invalid bits per sample:"
<< bitsPerSample;
return OpenResult::Aborted;
}
}
m_curFrameIndex = frameIndexMin();
return OpenResult::Succeeded;
}
示例15: Feature
SpectralCentroid::SpectralCentroid(int history_size, int spectrum_size, int sample_rate) : Feature(history_size) {
initialized = false;
barkWeights = NULL;
barkUnits = NULL;
setSpectrumSize(spectrum_size);
setSampleRate(sample_rate);
}