• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ov_open函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: loadOggSampleFromFile

bool loadOggSampleFromFile(const char *inFileURL, QuickVec<unsigned char> &outBuffer, int *channels, int *bitsPerSample, int* outSampleRate)
{
    FILE *f;

    //Read the file data
#ifdef ANDROID
    FileInfo info = AndroidGetAssetFD(inFileURL);
    f = fdopen(info.fd, "rb");
    fseek(f, info.offset, 0);
#else
    f = fopen(inFileURL, "rb");
#endif

    if (!f)
    {
        LOG_SOUND("FAILED to read sound file, file pointer as null?\n");
        return false;
    }

    OggVorbis_File oggFile;
    //Read the file data
#ifdef ANDROID
    ov_open(f, &oggFile, NULL, info.length);
#else
    ov_open(f, &oggFile, NULL, 0);
#endif

    return loadOggSample(oggFile, outBuffer, channels, bitsPerSample, outSampleRate);
}
开发者ID:AlexYates,项目名称:nme,代码行数:29,代码来源:Audio.cpp


示例2: OGG_length

//Inspired from ogginfo.c
// part of the vorbis-tools package of the OGG Vorbis project
int OGG_length(const char *filename)
{
  FILE *fp;
  OggVorbis_File vf;
  int rc,i;
  double playtime;

  memset(&vf,0,sizeof(OggVorbis_File));

  fp = fopen(filename,"r");
  if (!fp) {
    fprintf(stderr,"Unable to open \"%s\n", filename);
  }

  rc = ov_open(fp,&vf,NULL,0);

  if (rc < 0) {
    fprintf(stderr,"Unable to understand \"%s\", errorcode=%d\n", filename, rc);
    return 0;
  }

  playtime = (double) ov_time_total(&vf,-1);

//  printf("length (seconds) =%f\n",playtime);
//  printf("length (samples) =%d\n",((int) (playtime * 75)));

  ov_clear(&vf);

  return (int) (playtime * 75.0);
}
开发者ID:ProfessorKaos64,项目名称:hu-go,代码行数:32,代码来源:ogglength.c


示例3: LoadMusic

int LoadMusic(char *filename)
{
    FILE *f;

    /* First, open the file with the normal stdio interface. */

    if ((f = fopen(filename, "r")) ==  NULL)
    {
        printf("Unable to open music file %s.\n", filename);
        return -1;
    }

    /* Now pass it to libvorbis. */
    if (ov_open(f, &music_file, NULL, 0) < 0)
    {
        printf("Unable to attach libvorbis to %s.\n", filename);
        fclose(f);
        return -1;
    }

    /* Retrieve information about this stream. */
    music_info = ov_info(&music_file, -1);

    printf("Reading %li Hz, %i-channel music from %s.\n",
	   music_info->rate,
	   music_info->channels,
	   filename);
      
    music_file_loaded = 1;
	
    return 0;
}
开发者ID:newaowen,项目名称:Penguin-warrior,代码行数:32,代码来源:music.c


示例4: oggLoad

void oggLoad( SOggSound* o, const char* name )
{
  // file opening
  o->file = fopen( name, "rb");
  
  if( !o->file )
    {
      printf( "Sound error : %s !!!\n", name );
      return;
    }
  
  // with file, we open a ogg-vorbis stream
  if( ov_open( o->file, &o->stream, NULL, 0) )
    {
      printf( "Sound error : ogg stream error !!!\n" );
      return;
    }

  o->format = o->stream.vi->channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
  
  if( !alIsSource( o->source ) )
    {
      alGenSources( 1, &o->source );
      //printf( "create source.\n" );
    }
    
  soundCheckErrorAL( "load ogg" );
  soundCheckErrorALC( "load ogg" );
}
开发者ID:MaximeMorel,项目名称:OpenDD,代码行数:29,代码来源:sound.c


示例5: sprintf

bool WINCESdlMixerManager::checkOggHighSampleRate() {
	char trackFile[255];
	FILE *testFile;
	OggVorbis_File *test_ov_file = new OggVorbis_File;

	// FIXME: The following sprintf assumes that "path" is always
	// terminated by a path separator. This is *not* true in general.
	// This code really should check for the path separator, or even
	// better, use the FSNode API.
	sprintf(trackFile, "%sTrack1.ogg", ConfMan.get("path").c_str());
	// Check if we have an OGG audio track
	testFile = fopen(trackFile, "rb");
	if (testFile) {
		if (!ov_open(testFile, test_ov_file, NULL, 0)) {
			bool highSampleRate = (ov_info(test_ov_file, -1)->rate == 22050);
			ov_clear(test_ov_file);
			delete test_ov_file;
			return highSampleRate;
		}
	}

	// Do not test for OGG samples - too big and too slow anyway :)

	delete test_ov_file;
	return false;
}
开发者ID:project-cabal,项目名称:cabal,代码行数:26,代码来源:wincesdl-mixer.cpp


示例6: ov_open

    void cOggStream::Open(const string_t& path)
    {
      LOG<<"cOggStream::Open "<<path<<std::endl;

      if(!(oggFile = fopen(breathe::string::ToUTF8(path).c_str(), "rb"))) LOG<<"cOggStream::Open Could not open Ogg file "<<path<<std::endl;

      int result = ov_open(oggFile, &oggStream, NULL, 0);
      if (result < 0) {
        fclose(oggFile);

        LOG<<"cOggStream::Open Could not open Ogg stream "<<path<<" result="<<result<<std::endl;
      }

      vorbisInfo = ov_info(&oggStream, -1);
      vorbisComment = ov_comment(&oggStream, -1);

      if (vorbisInfo->channels == 1) format = AL_FORMAT_MONO16;
      else format = AL_FORMAT_STEREO16;

      alGenBuffers(BUFFER_NUMBER, buffers);
      ReportError();
      alGenSources(1, &source);
      ReportError();

      alSource3f(source, AL_POSITION, 0.0, 0.0, 0.0);
      alSource3f(source, AL_VELOCITY, 0.0, 0.0, 0.0);
      alSource3f(source, AL_DIRECTION, 0.0, 0.0, 0.0);
      alSourcef(source, AL_ROLLOFF_FACTOR, 0.0);
      alSourcei(source, AL_SOURCE_RELATIVE, AL_TRUE);

      LOG<<"cOggStream::Open "<<path<<" successfully opened, returning"<<std::endl;
    }
开发者ID:pilkch,项目名称:library,代码行数:32,代码来源:ogg.cpp


示例7: fopen

bool OggAudioSource::init(const RString& path, bool loadIntoMemory)
{
	if(mLoadedInMemory && loadIntoMemory)
		return true;

	mPath = path;
	mInFile = fopen(mPath.c_str(), "rb");

	if(mInFile == NULL)
	{
		std::cerr << "Cannot open " << mPath.c_str() << " for reading..." << std::endl;
		return false;
	}

	// Try opening the given file
	if(ov_open(mInFile, &mOggFile, NULL, 0) != 0)
	{
		std::cerr << "Error opening " << mPath.c_str() << " for decoding..." << std::endl;
		return false;
	}

	// Get some information about the OGG file
	mpOggInfo = ov_info(&mOggFile, -1);

	return BufferedAudioSource::init(path, loadIntoMemory);
}
开发者ID:Chenhx,项目名称:moai-dev,代码行数:26,代码来源:OggAudioSource.cpp


示例8: Java_com_badlogic_gdx_audio_io_VorbisDecoder_openFile

JNIEXPORT jlong JNICALL Java_com_badlogic_gdx_audio_io_VorbisDecoder_openFile(JNIEnv *env, jobject, jstring filename)
{
	char* fileString = (char*)env->GetStringUTFChars(filename, NULL);
	OggVorbis_File* ogg = new OggVorbis_File();
	FILE* file = fopen(fileString, "rb" );
	env->ReleaseStringUTFChars( filename, fileString );

	if( file == 0 )
	{
		delete ogg;
		return 0;
	}

	if( ov_open( file, ogg, NULL, 0 ) != 0 )
	{
		fclose( file );
		delete ogg;
		return 0;
	}

	vorbis_info *info = ov_info( ogg, -1 );
	int channels = info->channels;
	int rate = info->rate;
	float length = (float)ov_time_total(ogg, -1 ) / 1000.0f;

	OggFile* oggFile = new OggFile();
	oggFile->ogg = ogg;
	oggFile->channels = channels;
	oggFile->rate = rate;
	oggFile->length = length;

	return (jlong)oggFile;
}
开发者ID:AlexPetraglia,项目名称:libgdx,代码行数:33,代码来源:VorbisDecoder.cpp


示例9: vorbis_open

int vorbis_open(const char *file) {
	FILE *fp;
	vorbis_info *info;
	
	if (!file || !*file)
		return 0;

	if (!(fp = fopen(file, "rb")))
		return 0;

	if (ov_open(fp, &track, NULL, 0)) {
		fclose(fp);
		return 0;
	}

	parse_comments(ov_comment(&track, -1));
	
	info = ov_info(&track, -1);
	
	sample_rate = info->rate;
	channels = info->channels;
	duration = ov_time_total(&track, -1);
	bitrate = ov_bitrate(&track, -1);

	return 1;
}
开发者ID:playya,项目名称:Enlightenment,代码行数:26,代码来源:vorbis.c


示例10: OggVorbis_File

	 static inline jlong wrapped_Java_com_badlogic_gdx_audio_io_VorbisDecoder_openFile
(JNIEnv* env, jclass clazz, jstring obj_filename, char* filename) {

//@line:125

		OggVorbis_File* ogg = new OggVorbis_File();
		FILE* file = fopen(filename, "rb" );
	
		if( file == 0 )
		{
			delete ogg;
			return 0;
		}
	
		if( ov_open( file, ogg, NULL, 0 ) != 0 )
		{
			fclose( file );
			delete ogg;
			return 0;
		}
	
		vorbis_info *info = ov_info( ogg, -1 );
		int channels = info->channels;
		int rate = info->rate;
		float length = (float)ov_time_total(ogg, -1 ) / 1000.0f;
	
		OggFile* oggFile = new OggFile();
		oggFile->ogg = ogg;
		oggFile->channels = channels;
		oggFile->rate = rate;
		oggFile->length = length;
	
		return (jlong)oggFile;	
	
}
开发者ID:0302zq,项目名称:libgdx,代码行数:35,代码来源:com.badlogic.gdx.audio.io.VorbisDecoder.cpp


示例11: getMusStr

QString getMusStr(const char *fileE, int type, QPixmap &pix)
{
	QString musStr;
	pix = NULL;
	if ( type == 0 )
	{
		if ( tag_editor )
		{
			musStr = tag_editor->getData( fileE, NULL );
			if ( !musStr.isEmpty() )
				musStr = "\n"+musStr;
			return musStr;
		}
		OggVorbis_File mus;
		FILE *fil = NULL;
		fil = qmp_fopen(fileE,"rb");
		if ( ov_open(fil,&mus,NULL,0) )
		{
			if (fil)
				fclose(fil);
			return "";
		}

		getMusInfo( mus, NULL, NULL, NULL, NULL, &musStr );
		musStr = "\n" + musStr;

		ov_clear(&mus);
	}
	return musStr;
}
开发者ID:darwinbeing,项目名称:Hifi-Pod,代码行数:30,代码来源:vorbis_pl.cpp


示例12: URLToFilePath

uint32 VorbisLMC::CalculateSongLength(const char *url)
{
    char            path[_MAX_PATH];
    uint32          len = _MAX_PATH;
    FILE           *fpFile;
    OggVorbis_File  vf;
    double          dur;

    URLToFilePath(url, path, &len);
    fpFile = fopen(path, "rb");
    if (fpFile == NULL)
       return 0;  

    memset(&vf, 0, sizeof(vf));
    if (ov_open(fpFile, &vf, NULL, 0) < 0)
    {
       fclose(fpFile);
       return 0; 
    }

    dur = ov_time_total(&vf, 0);

    ov_clear(&vf);

    return (int)dur;
}
开发者ID:pontocom,项目名称:opensdrm,代码行数:26,代码来源:vorbislmc.cpp


示例13: closeFile

bool AudioStreamOGG::openFile(const io::stringc &Filename)
{
    closeFile();
    
    s32 Result = 0;
    
    /* Open file */
    if ( !( OggFile_ = fopen(Filename.c_str(), "rb") ) )
    {
        io::Log::error("Could not open 'Ogg Vorbis' file");
        return false;
    }
    
    /* Open ogg vorbis file stream */
    if ( ( Result = ov_open(OggFile_, &OggStream_, 0, 0) ) < 0 )
    {
        fclose(OggFile_);
        io::Log::error("Could not open 'Ogg Vorbis' stream (" + AudioStreamOGG::getErrorString(Result) + ")");
        return false;
    }
    
    /* Get stream information */
    VorbisInfo_ = ov_info(&OggStream_, -1);
    VorbisComment_ = ov_comment(&OggStream_, -1);
    
    if (VorbisInfo_->channels == 1)
        Format_ = WAVECHANNEL_MONO16;
    else
        Format_ = WAVECHANNEL_STEREO16;
    
    return true;
}
开发者ID:bekasov,项目名称:SoftPixelEngine,代码行数:32,代码来源:spAudioStreamOGG.cpp


示例14: infoWindow

void infoWindow( QWidget *w, const char *fileE, int type )
{
	if ( type != 0 )
		return;

	if ( tag_editor )
	{
		tag_editor->openWindow( fileE, w, false, false );
		return;
	}

	OggVorbis_File mus;

	FILE *fil = qmp_fopen( fileE, "rb" );
	if ( ov_open(fil,&mus,NULL,0) )
	{
		if (fil)
			fclose(fil);
		ov_clear(&mus);
		return;
	}

	QString txt;
	getMusInfo( mus, NULL, NULL, NULL, NULL, &txt );
	txt = "\n\n" + txt;

	ov_clear(&mus);

	QMessageBox::information( w, PlugInfoStr, "File path: \"" + QString( fileE ) + "\"" + txt);
}
开发者ID:darwinbeing,项目名称:Hifi-Pod,代码行数:30,代码来源:vorbis_pl.cpp


示例15: console

int Audio::loadFakeOgg(Path file){
	
	AudioSource* source=new AudioSource;

	source->filename=file;
	source->type=AUDIO_OGG;

	if(!(source->oggFile = fopen(file.getAbsolute().c_str(), "rb"))){
		console().write("audio error: i/o error, could not open off file '"+file.getRelative()+"'");
		return -1;
	}

	int result;

	if((result = ov_open(source->oggFile, &source->oggStream, NULL, 0)) < 0){
		fclose(source->oggFile);
        
		console().write("audio error: could not open ogg stream '"+file.getRelative()+"'");
		return -1;
	}

	source->fakeLen=ov_time_total(&source->oggStream,-1);

	sources.pushBack(source);
	source->sourceIndex=sources.size()-1;
	return sources.size()-1;

}
开发者ID:jameshegarty,项目名称:bajaengine,代码行数:28,代码来源:Audio.cpp


示例16: LoadOGG

int SoundManager::LoadOGG(WAVEFORMATEX* fformat, unsigned char** sample_data, size_t* size_data, char* ogg_path)
{
  FILE *fs;
  if(!(fs=fopen(ogg_path,"rb"))) return 0;

  OggVorbis_File vf;
  if(ov_open(fs,&vf,NULL,0)) return 0;
  vorbis_info* vi=ov_info(&vf,-1);

  int data_len=(int)ov_pcm_total(&vf,-1);
  int start_pos=(int)ov_pcm_tell(&vf);

  int BPS=vi->channels==1?2:4;
  *size_data=(data_len-start_pos)*BPS;

  *sample_data=new unsigned char[*size_data];

  size_t decoded=0;

  while (decoded < *size_data) {
    int curr;
    decoded += ov_read(&vf,(char*)(*sample_data)+decoded,(*size_data)-decoded,0,2,1,&curr);
  }

  fformat->wFormatTag=WAVE_FORMAT_PCM;
  fformat->nChannels=vi->channels;
  fformat->nSamplesPerSec=vi->rate;
  fformat->wBitsPerSample=16;
  fformat->nBlockAlign=vi->channels*fformat->wBitsPerSample/8;
  fformat->nAvgBytesPerSec=fformat->nBlockAlign*vi->rate;
  fformat->cbSize=0;

  return 1;
}
开发者ID:BHjr132,项目名称:fonline,代码行数:34,代码来源:SoundMngr.cpp


示例17: fopen

int FileVorbis::check_sig(Asset *asset)
{
// FILEVORBIS DECODING IS DISABLED
	return 0;
	FILE *fd = fopen(asset->path, "rb");
	OggVorbis_File vf;

// Test for Quicktime since OGG misinterprets it
	fseek(fd, 4, SEEK_SET);
	char data[4];
	fread(data, 4, 1, fd);
	if(data[0] == 'm' &&
		data[1] == 'd' &&
		data[2] == 'a' &&
		data[3] == 't')
	{
		fclose(fd);
		return 0;
	}
	
	fseek(fd, 0, SEEK_SET);

	if(ov_open(fd, &vf, NULL, 0) < 0)
	{
// OGG failed.  Close file handle manually.
		ov_clear(&vf);
		if(fd) fclose(fd);
		return 0;
	}
	else
	{
		ov_clear(&vf);
		return 1;
	}
}
开发者ID:beequ7et,项目名称:cinelerra-cv,代码行数:35,代码来源:filevorbis.C


示例18: fopen

void Stream::loadOgg(const char *filename)
{
   sound = filename;

   file = fopen(filename, "rb");
   if (!file)
      throw RubyException(rb_eRuntimeError, "Cannot open the stream file.");
   ov_open(file, &stream, NULL, 0);

   info = ov_info(&stream, -1);
   comment = ov_comment(&stream, -1);

   format = SAMPLES_FORMAT;
   
   alGenBuffers(2, buffers);
   if (alGetError() != AL_NO_ERROR)
      throw RubyException(rb_eRuntimeError, "Cannot generate the buffer.");

   generateSource();
   if (alGetError() != AL_NO_ERROR)
     throw RubyException(rb_eRuntimeError, "Cannot generate sources.");

   setPos(0.f, 0.f, 0.f);
   setVelocity(0.f, 0.f, 0.f);
   setDirection(0.f, 0.f, 0.f);

   setPitch(1.f);
   setGain(1.f);
}
开发者ID:bruni68510,项目名称:Joyau,代码行数:29,代码来源:Audio.cpp


示例19: memset

/* Load an OGG stream from the given file */
OGG_music *OGG_new(const char *file)
{
	OGG_music *music;
	FILE *fp;

	music = (OGG_music *)malloc(sizeof *music);
	if ( music ) {
		/* Initialize the music structure */
		memset(music, 0, (sizeof *music));
		OGG_stop(music);
		OGG_setvolume(music, MIX_MAX_VOLUME);
		music->section = -1;

		fp = fopen(file, "rb");
		if ( fp == NULL ) {
			SDL_SetError("Couldn't open %s", file);
			free(music);
			return(NULL);
		}
		if ( ov_open(fp, &music->vf, NULL, 0) < 0 ) {
			SDL_SetError("Not an Ogg Vorbis audio stream");
			free(music);
			fclose(fp);
			return(NULL);
		}
	} else {
		SDL_SetError("Out of memory");
	}
	return(music);
}
开发者ID:Jay-Jay-OPL,项目名称:ps2sdk-ports,代码行数:31,代码来源:music_ogg.c


示例20: file

/*
==========
OGG_Open

Play Ogg Vorbis file (with absolute or relative index).
==========
*/
qboolean OGG_Open(ogg_seek_t type, int offset)
{
	int		 size;		/* File size. */
	int		 pos;		/* Absolute position. */
	int		 res;		/* Error indicator. */

	pos = -1;

	switch (type) {
	case ABS:
		/* Absolute index. */
		if (offset < 0 || offset >= ogg_numfiles) {
			Com_Printf("OGG_Open: %d out of range.\n", offset+1);
			return (false);
		} else
			pos = offset;
		break;
	case REL:
		/* Simulate a loopback. */
		if (ogg_curfile == -1 && offset < 0)
			offset++;
		while (ogg_curfile + offset < 0)
			offset += ogg_numfiles;
		while (ogg_curfile + offset >= ogg_numfiles)
			offset -= ogg_numfiles;
		pos = ogg_curfile + offset;
		break;
	}

	/* Check running music. */
	if (ogg_status == PLAY) {
		if (ogg_curfile == pos)
			return (true);
		else
			OGG_Stop();
	}

	/* Find file. */
	if ((size = FS_LoadFile(ogg_filelist[pos], (void **)&ogg_buffer)) == -1) {
		Com_Printf("OGG_Open: could not open %d (%s): %s.\n", pos, ogg_filelist[pos], strerror(errno));
		return (false);
	}

	/* Open ogg vorbis file. */
	if ((res = ov_open(NULL, &ovFile, (char *)ogg_buffer, size)) < 0) {
		Com_Printf("OGG_Open: '%s' is not a valid Ogg Vorbis file (error %i).\n", ogg_filelist[pos], res);
		FS_FreeFile(ogg_buffer);
		return (false);
	}

	/* Play file. */
	ovSection = 0;
	ogg_curfile = pos;
	ogg_status = PLAY;

	Com_Printf("Playing file %d '%s'\n", pos, ogg_filelist[pos]);

	return (true);
}
开发者ID:ZwS,项目名称:qudos,代码行数:66,代码来源:snd_ogg.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ov_open_callbacks函数代码示例发布时间:2022-05-30
下一篇:
C++ outw函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap