当前位置: 首页>>代码示例>>C++>>正文


C++ SoundFile类代码示例

本文整理汇总了C++中SoundFile的典型用法代码示例。如果您正苦于以下问题:C++ SoundFile类的具体用法?C++ SoundFile怎么用?C++ SoundFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SoundFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

////////////////////////////////////////////////////////////
/// Create a new sound from a file, for writing
////////////////////////////////////////////////////////////
SoundFile* SoundFile::CreateWrite(const std::wstring& Filename, unsigned int ChannelsCount, unsigned int SampleRate)
{
    // Create the file according to its type
    SoundFile* File = NULL;
    if      (SoundFileOgg::IsFileSupported(Filename, false))     File = new SoundFileOgg;
    else if (SoundFileDefault::IsFileSupported(Filename, false)) File = new SoundFileDefault;

    // Open it for writing
    if (File)
    {
        if (File->OpenWrite(Filename, ChannelsCount, SampleRate))
        {
            File->myFilename      = L"";
            File->myData          = NULL;
            File->mySize          = 0;
            File->myNbSamples     = 0;
            File->myChannelsCount = ChannelsCount;
            File->mySampleRate    = SampleRate;
        }
        else
        {
            delete File;
            File = NULL;
        }
    }

    return File;
}
开发者ID:laie,项目名称:Mgine,代码行数:31,代码来源:SoundFile.cpp

示例2: SoundFile_is_finished

static VALUE SoundFile_is_finished(VALUE self) 
{
  SoundFile *soundfile;
  Data_Get_Struct(self, SoundFile, soundfile);
  
  return (soundfile->is_finished())? Qtrue : Qfalse;
}
开发者ID:dmichael,项目名称:code-samples,代码行数:7,代码来源:ruby_soundfile.cpp

示例3:

TimeStretcher::TimeStretcher(const SoundFile &soundFile) {
    this->soundFile = soundFile;
    channels = soundFile.getChannels();
    inputSamples = soundFile.getSamples();

    stretchInBufL.resize(maxProcessSize);
    stretchInBufR.resize(maxProcessSize);
    stretchInBuf.resize(channels);
    stretchInBuf[0] = &(stretchInBufL[0]);
    stretchInBuf[1] = &(stretchInBufR[0]);

    stretchOutBufL.resize(maxProcessSize);
    stretchOutBufR.resize(maxProcessSize);
    stretchOutBuf.resize(channels);
    stretchOutBuf[0] = &(stretchOutBufL[0]);
    stretchOutBuf[1] = &(stretchOutBufR[0]);

    rubberband = new RubberBand::RubberBandStretcher(
            soundFile.getSampleRate(), channels,
            RubberBand::RubberBandStretcher::DefaultOptions |
            RubberBand::RubberBandStretcher::OptionProcessRealTime);
    rubberband->setMaxProcessSize(maxProcessSize);

    playheadPos = 0;
}
开发者ID:brsaylor,项目名称:TuneTutor-proto,代码行数:25,代码来源:timestretcher.cpp

示例4: SoundFile_restart

static VALUE SoundFile_restart(VALUE self) 
{
  SoundFile *ugen;
  Data_Get_Struct(self, SoundFile, ugen);
  ugen->reset();
  return Qtrue;
}
开发者ID:dmichael,项目名称:code-samples,代码行数:7,代码来源:ruby_soundfile.cpp

示例5: SoundFile_duration

static VALUE SoundFile_duration(VALUE self) 
{
  SoundFile *ugen;
  Data_Get_Struct(self, SoundFile, ugen);
  
  StkFloat duration = ugen->durationInSeconds();
	return rb_float_new(duration);
}
开发者ID:dmichael,项目名称:code-samples,代码行数:8,代码来源:ruby_soundfile.cpp

示例6: SoundFile_duration_samples

static VALUE SoundFile_duration_samples(VALUE self) 
{
  SoundFile *ugen;
  Data_Get_Struct(self, SoundFile, ugen);
  
  unsigned long duration = ugen->durationInSamples();
	return LONG2NUM(duration);
}
开发者ID:dmichael,项目名称:code-samples,代码行数:8,代码来源:ruby_soundfile.cpp

示例7: concatFiles

void ConcatService::concatFiles(vector<SoundFile*> soundFiles) {
    SoundFile soundFile = *soundFiles[0];
    int i;
    for(i = 1; i < numberOfSoundFiles; i++) {
        soundFile += soundFiles[i];
    }
    if(outputFileName.compare(" ")) {
        if((outputFileName.find(".cs229") == string::npos) ) {
            __throw_invalid_argument("Invalid output file, must use an output file that ends with .cs229");
        }
    }
    soundFile.writeCS229File(outputFileName);
}
开发者ID:JeffHask,项目名称:CS327Project4,代码行数:13,代码来源:ConcatService.cpp

示例8: LOG

void ISoundDevice::play(const char *filename, Dumais::Sound::SoundFormat format)
{
    if (this->getSampleSize() == 0) return;
    LOG("Adding " << filename << " in sound device queue");
    SoundFile *file = new SoundFile();
    if (file->open(filename,format))
    {
        this->mSoundQueue.put(file);
        this->setWorking();
    } else {
        delete file;
    }
}
开发者ID:pdumais,项目名称:dhas,代码行数:13,代码来源:ISoundDevice.cpp

示例9: getActiveSoundFile

void GData::saveActiveFile() {
  SoundFile *s = getActiveSoundFile();
  if(!s) return;
  if(s->saved()) return;
  if(audioThread.playSoundFile() == s || audioThread.recSoundFile() == s) {
    stop();
  }
  int val = saveFile(s, saveFileAsk(s->filename));
  if(val == 0) { //success
    emit channelsChanged();
  } else if(val == -1) {
    QMessageBox::warning(mainWindow, "Error", QString("Error saving file '") + QString(s->filename) + QString("'"), QMessageBox::Ok, Qt::NoButton);
  }
}
开发者ID:nsauzede,项目名称:tartini,代码行数:14,代码来源:gdata.cpp

示例10: SoundFile_set_rate

static VALUE SoundFile_set_rate(VALUE self, VALUE rate) 
{
  // get the Unit instance
  SoundFile *ugen;
  Data_Get_Struct(self, SoundFile, ugen); 
  
  if(TYPE(rate) == T_FLOAT || TYPE(rate) == T_FIXNUM){
    float rate_f = (float) NUM2DBL(rate);
    // set the frequency
    ugen->setRate(rate_f);
    // store what was set in the instance variable
    rb_iv_set(self, "@rate", rate);
  }
	return rate;
}
开发者ID:dmichael,项目名称:code-samples,代码行数:15,代码来源:ruby_soundfile.cpp

示例11: fillWidget

void ReorderDialog::fillWidget(int selection){
    ui->listWidget->clear();

    QStringList strings;
    const QList<SoundFile *> *files = list->getList();
    QList<SoundFile *>::const_iterator iter;
    for(iter = files->begin(); iter != files->end(); iter++){
        SoundFile *file = *iter;
        strings << file->getDescription();
    }

    ui->listWidget->addItems(strings);
    ui->listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
    ui->listWidget->setCurrentRow(selection);
}
开发者ID:ruedigergad,项目名称:stultitiasimplex,代码行数:15,代码来源:reorderdialog.cpp

示例12: _T

	void AudioManager::LoadMusic(
		const tstring& path,
		const tstring& name,
		float32 volume,
		uint8 channel
		)
	{
		Logger::GetInstance()->Log(mSoundService != nullptr,
			_T("Sound Service is invalid."), STARENGINE_LOG_TAG);

		if(mMusicList.find(name) != mMusicList.end())
		{
			Logger::GetInstance()->Log(LogLevel::Warning,
				_T("Sound Service: The music file '") + name +
				_T("' is already loaded."), STARENGINE_LOG_TAG);
			return;
		}

		auto pathit = mMusicPathList.find(path);
		if(pathit != mMusicPathList.end())
		{
			star::Logger::GetInstance()->Log(LogLevel::Warning,
				_T("Sound Service : Sound File Path Already Exists"),
				STARENGINE_LOG_TAG);
			tstring nameold = pathit->second;
			auto nameit = mMusicList.find(nameold);
			if(nameit != mMusicList.end())
			{
				star::Logger::GetInstance()->Log(LogLevel::Warning,
					_T("Sound Service: Found sound file of old path, making copy for new name"),
					STARENGINE_LOG_TAG);
				mMusicList[name] = nameit->second;
				return;
			}
			mMusicPathList.erase(pathit);
			return;
		}

		SoundFile* music = new SoundFile(path, channel);
		music->SetCompleteVolume(
			volume,
			GetChannelVolume(channel),
			GetVolume()
			);
		mMusicList[name] = music;
		mMusicPathList[path] = name;
		return;
	}
开发者ID:Syvion,项目名称:StarEngine,代码行数:48,代码来源:AudioManager.cpp

示例13: SoundFile_open

static VALUE SoundFile_open(VALUE self, VALUE filename) 
{
  // We want a string here...
  Check_Type(filename, T_STRING);
  // get the Unit instance
  SoundFile *ugen;
  Data_Get_Struct(self, SoundFile, ugen);

  // Open the file, rethrowing errors as necessary  
  try {
    ugen->open(StringValuePtr(filename));  
  }
  catch(StkError &error) {
    return self;
  }
	return self;
}
开发者ID:dmichael,项目名称:code-samples,代码行数:17,代码来源:ruby_soundfile.cpp

示例14: SoundFile_initialize

static VALUE SoundFile_initialize(int argc, VALUE *argv, VALUE self)
{
  VALUE options;
  /* One mandatory, one optional argument */
  rb_scan_args(argc, argv, "01", &options);
  
  SoundFile *soundfileugen;
  Data_Get_Struct(self, SoundFile, soundfileugen);
  
  if(options != Qnil){
    Check_Type(options, T_HASH);
    VALUE filename = rb_hash_aref(options, ID2SYM(rb_intern("file")));     
    
    soundfileugen->open(StringValuePtr(filename));
  }    
	return self;
}
开发者ID:dmichael,项目名称:code-samples,代码行数:17,代码来源:ruby_soundfile.cpp

示例15: SoundFile

SoundFile* AudioOutputSample::loadSndfile(const QString &filename) {
	SoundFile *sf;

	// Create the filehandle and do a quick check if everything is ok
	sf = new SoundFile(filename);

	if (! sf->isOpen()) {
		qWarning() << "File " << filename << " failed to open";
		delete sf;
		return NULL;
	}

	if (sf->error() != SF_ERR_NO_ERROR) {
		qWarning() << "File " << filename << " couldn't be loaded: " << sf->strError();
		delete sf;
		return NULL;
	}

	if (sf->channels() <= 0 || sf->channels() > 2) {
		qWarning() << "File " << filename << " contains " << sf->channels() << " Channels, only 1 or 2 are supported.";
		delete sf;
		return NULL;
	}
	return sf;
}
开发者ID:EarlOfWenc,项目名称:mumble,代码行数:25,代码来源:AudioOutputSample.cpp


注:本文中的SoundFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。