本文整理汇总了C++中ov_open函数的典型用法代码示例。如果您正苦于以下问题:C++ ov_open函数的具体用法?C++ ov_open怎么用?C++ ov_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ov_open函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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;
}
示例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" );
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}