本文整理汇总了C++中BASS_StreamCreateFile函数的典型用法代码示例。如果您正苦于以下问题:C++ BASS_StreamCreateFile函数的具体用法?C++ BASS_StreamCreateFile怎么用?C++ BASS_StreamCreateFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BASS_StreamCreateFile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: BASS_StreamCreateFile
void NLS::Sound::Play(bool loop) {
if (!stream) {
if (loop) {
stream = BASS_StreamCreateFile(true, data->data, 0, data->len, BASS_SAMPLE_FLOAT|BASS_SAMPLE_LOOP);
} else {
stream = BASS_StreamCreateFile(true, data->data, 0, data->len, BASS_SAMPLE_FLOAT);
}
}
BASS_ChannelPlay(stream, !loop);
}
开发者ID:NoLifeDev,项目名称:OldNoLifeStoryOne,代码行数:10,代码来源:Sound.cpp
示例2: PlayFile
// select a file to play, and start scanning it
BOOL PlayFile()
{
char file[MAX_PATH]="";
OPENFILENAME ofn={0};
ofn.lStructSize=sizeof(ofn);
ofn.hwndOwner=win;
ofn.nMaxFile=MAX_PATH;
ofn.lpstrFile=file;
ofn.Flags=OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_EXPLORER;
ofn.lpstrTitle="Select a file to play";
ofn.lpstrFilter="Playable files\0*.mp3;*.mp2;*.mp1;*.ogg;*.wav;*.aif;*.mo3;*.it;*.xm;*.s3m;*.mtm;*.mod;*.umx\0All files\0*.*\0\0";
if (!GetOpenFileName(&ofn)) return FALSE;
if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,0))
&& !(chan=BASS_MusicLoad(FALSE,file,0,0,BASS_MUSIC_RAMPS|BASS_MUSIC_POSRESET|BASS_MUSIC_PRESCAN,1))) {
Error("Can't play file");
return FALSE; // Can't load the file
}
{
BYTE data[2000]={0};
BITMAPINFOHEADER *bh=(BITMAPINFOHEADER*)data;
RGBQUAD *pal=(RGBQUAD*)(data+sizeof(*bh));
int a;
bh->biSize=sizeof(*bh);
bh->biWidth=WIDTH;
bh->biHeight=-HEIGHT;
bh->biPlanes=1;
bh->biBitCount=8;
bh->biClrUsed=bh->biClrImportant=HEIGHT/2+1;
// setup palette
for (a=1;a<=HEIGHT/2;a++) {
pal[a].rgbRed=(255*a)/(HEIGHT/2);
pal[a].rgbGreen=255-pal[a].rgbRed;
}
// create the bitmap
wavebmp=CreateDIBSection(0,(BITMAPINFO*)bh,DIB_RGB_COLORS,(void**)&wavebuf,NULL,0);
wavedc=CreateCompatibleDC(0);
SelectObject(wavedc,wavebmp);
}
bpp=BASS_ChannelGetLength(chan,BASS_POS_BYTE)/WIDTH; // bytes per pixel
{
DWORD bpp1=BASS_ChannelSeconds2Bytes(chan,0.001); // minimum 1ms per pixel
if (bpp<bpp1) bpp=bpp1;
}
BASS_ChannelSetSync(chan,BASS_SYNC_END|BASS_SYNC_MIXTIME,0,LoopSyncProc,0); // set sync to loop at end
BASS_ChannelPlay(chan,FALSE); // start playing
{ // create another channel to scan
DWORD chan2=BASS_StreamCreateFile(FALSE,file,0,0,BASS_STREAM_DECODE);
if (!chan2) chan2=BASS_MusicLoad(FALSE,file,0,0,BASS_MUSIC_DECODE,1);
scanthread=_beginthread(ScanPeaks,0,(void*)chan2); // start scanning in a new thread
}
return TRUE;
}
开发者ID:Emulai,项目名称:ICT397-Project,代码行数:54,代码来源:custloop.c
示例3: OpenClicked
void OpenClicked(GtkButton *obj, gpointer data)
{
int resp=gtk_dialog_run(GTK_DIALOG(filesel));
gtk_widget_hide(filesel);
if (resp==GTK_RESPONSE_ACCEPT) {
char *file=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filesel));
// free both MOD and stream, it must be one of them! :)
BASS_MusicFree(chan);
BASS_StreamFree(chan);
if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_LOOP|BASS_SAMPLE_FLOAT))
&& !(chan=BASS_MusicLoad(FALSE,file,0,0,BASS_MUSIC_RAMPS|BASS_SAMPLE_LOOP|BASS_SAMPLE_FLOAT,1))) {
// whatever it is, it ain't playable
gtk_button_set_label(obj,"click here to open a file...");
Error("Can't play the file");
} else {
BASS_CHANNELINFO info;
BASS_ChannelGetInfo(chan,&info);
if (info.chans!=2) { // the DSP expects stereo
gtk_button_set_label(obj,"click here to open a file...");
BASS_MusicFree(chan);
BASS_StreamFree(chan);
Error("only stereo sources are supported");
} else {
gtk_button_set_label(obj,file);
// setup DSPs on new channel and play it
RotateToggled(GTK_TOGGLE_BUTTON(GetWidget("rotate")),0);
EchoToggled(GTK_TOGGLE_BUTTON(GetWidget("echo")),0);
FlangerToggled(GTK_TOGGLE_BUTTON(GetWidget("flanger")),0);
BASS_ChannelPlay(chan,FALSE);
}
}
g_free(file);
}
}
开发者ID:AntonGerasimov,项目名称:Converter,代码行数:34,代码来源:dsptest.c
示例4: Thread
/*
Поток для загрузки музыки в плейлист
*/
DWORD WINAPI Thread(LPVOID lp)
{
HDROP hDrop = (HDROP)lp;
CHAR szFileName[MAX_PATH];
TCHAR buff[MAX_PATH];
DWORD dwCount = DragQueryFileA(hDrop, 0xFFFFFFFF, szFileName, MAX_PATH); //Определение количества загружаемых песен
for (INT i = 0; i < dwCount; i++)
{
DragQueryFileA(hDrop, i, szFileName, MAX_PATH); //Определение пути к файлу
INT len = strlen(szFileName);
CHAR buffFormat[4]; //Формат песни
INT j = 0; //для прохода по буферу формата песни
for (INT i = len - 4; i < len; i++)
{
buffFormat[j] = szFileName[i];
j++;
}
if (me_strcmp(".mp3", buffFormat))
{
HSTREAM stream = BASS_StreamCreateFile(0, szFileName, 0, 0, 0); //Создание потока
mbstowcs(buff, szFileName, MAX_PATH); //преобразование CHAR to TCHAR
DlgPlayList::_this->addSongToPlayList(stream, buff); //Добавление песни в плейлист
}
}
DragFinish(hDrop);
return FALSE;
}
开发者ID:vitahalyubimov,项目名称:Course-WinAPI,代码行数:30,代码来源:DlgPlayList.cpp
示例5: BASS_StreamCreateFile
bool CBackgroundAudio::InitializeBASS()
{
bool bBassInitializedSuccessfully = false;
//BASS default device constant
const int kBASSDefaultDevice = -1;
//Output rate of 44.1 kHz...
const int kOutputRateHz = 44100;
//Initialize the BASS library..
if(::BASS_Init(kBASSDefaultDevice, kOutputRateHz, 0, 0, NULL) &&
this->mpFileBuffer && (this->mFileBufferSize > 0)) {
//Create a BASS audio stream, using the file in the memory
//buffer (the stream will be looped, as indicated by the appropriate
//flag)...
HSTREAM hBassAudioStream =
BASS_StreamCreateFile(true, this->mpFileBuffer, 0,
this->mFileBufferSize, BASS_SAMPLE_LOOP);
if(hBassAudioStream) {
this->mhBassAudioStream = hBassAudioStream;
}
}
return(bBassInitializedSuccessfully);
}
开发者ID:Ayodeji-O,项目名称:ClothScrollerDemo,代码行数:27,代码来源:BackgroundAudio.cpp
示例6: QDEBUG
/**
* @brief No incoming parameters. Get data from RCHAN. Creating the stream file. If BASS_StreamCreateFile is failure colled BASS_Free().
* @param No params
*/
void Widget::stopRecording()
{
if (BASS_ChannelGetData(rchan, this->fft, BASS_DATA_FFT1024 | BASS_DATA_FFT_COMPLEX) == -1) {
QDEBUG("Cannot get recbuf from rchan");
QDEBUG(BASS_ErrorGetCode());
}
BASS_ChannelStop(rchan);
rchan=0;
ui->pushButton->setText(tr("Record"));
// complete the WAVE header
*(DWORD*)(recbuf+4)=reclen-8;
*(DWORD*)(recbuf+40)=reclen-44;
// enable "save" button
ui->pushButton_3->setEnabled(true);
// setup output device (using default device)
if (!BASS_Init(-1,44100,0,NULL,NULL)) {
QDEBUG(BASS_ErrorGetCode());
QDEBUG("Can't initialize output device");
return;
}
// create a stream from the recording
if (chan=BASS_StreamCreateFile(TRUE,recbuf,0,reclen,BASS_SAMPLE_FLOAT)) {
//ui->pushButton_2->setEnabled(true); // enable "play" button
}
else
BASS_Free();
ui->pushButton->setEnabled(true);
}
开发者ID:lovelycodex,项目名称:diplom,代码行数:33,代码来源:widget.cpp
示例7: PlayFile
// select a file to play, and play it
BOOL PlayFile()
{
BOOL ret=FALSE;
NavDialogRef fileDialog;
NavDialogCreationOptions fo;
NavGetDefaultDialogCreationOptions(&fo);
fo.optionFlags=0;
fo.parentWindow=win;
NavCreateChooseFileDialog(&fo,NULL,NULL,NULL,NULL,NULL,&fileDialog);
if (!NavDialogRun(fileDialog)) {
NavReplyRecord r;
if (!NavDialogGetReply(fileDialog,&r)) {
AEKeyword k;
FSRef fr;
if (!AEGetNthPtr(&r.selection,1,typeFSRef,&k,NULL,&fr,sizeof(fr),NULL)) {
char file[256];
FSRefMakePath(&fr,(BYTE*)file,sizeof(file));
if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_LOOP))
&& !(chan=BASS_MusicLoad(FALSE,file,0,0,BASS_MUSIC_RAMP|BASS_SAMPLE_LOOP,1))) {
Error("Can't play file");
} else {
BASS_ChannelPlay(chan,FALSE);
ret=TRUE;
}
}
NavDisposeReply(&r);
}
}
NavDialogDispose(fileDialog);
return ret;
}
开发者ID:bagnz0r,项目名称:ichigo-audio,代码行数:32,代码来源:spectrum.c
示例8: Music_decode
int Music_decode(text_t* path, MusicData* data)
{
QWORD len;
thrd_t id;
if (thrd_busy == mtx_trylock(&s_mutex))
{
Dialog_showError(TEXT("Decoding of stream already in-progress. Re-open after it's been completed."));
return 1;
}
// now this will break if we already have a thread running.
free(data->fftData);
data->fftData = 0;
int flags = BASS_STREAM_DECODE | BASS_SAMPLE_MONO | BASS_POS_SCAN;
#ifdef _WIN32
flags |= BASS_UNICODE;
#endif
HSTREAM chan = BASS_StreamCreateFile(0, path, 0, 0, flags);
if (!chan)
{
Dialog_showError(TEXT("Unable to open stream for decode. No music data will be available."));
mtx_unlock(&s_mutex);
return 0;
}
len = BASS_ChannelGetLength(chan, BASS_POS_BYTE);
if (len == -1)
{
Dialog_showError(TEXT("Stream has no length. No music data will be available."));
BASS_StreamFree(chan);
mtx_unlock(&s_mutex);
return 0;
}
ThreadFuncData* threadData = malloc(sizeof(ThreadFuncData));
threadData->stream = chan;
threadData->data = data;
data->percentDone = 1;
data->fftData = 0;
// So there is a race-condition here as the mutex is unclocked while the thread is crated but in practice
// this won't be a problem
mtx_unlock(&s_mutex);
if (thrd_create(&id, decodeFunc, threadData) != thrd_success)
{
printf("Unable to create decode thread. Stalling main thread and running...\n");
decodeFunc(threadData);
}
return 1;
}
开发者ID:emoon,项目名称:rocket,代码行数:60,代码来源:MusicDecode.c
示例9: setupSDL
render::render(char* song, bool play) {
this->play = play;
running = setupSDL();
if (play) {
BASS_Init(-1, 44100, 0, NULL, NULL);
HSTREAM stream;
stream = BASS_StreamCreateFile(false, song, 0, 0, BASS_SAMPLE_FLOAT | BASS_STREAM_PRESCAN);
sound_chan = stream;
BASS_ChannelPlay(sound_chan, false);
}
srand(time(NULL));
for (int i = 0; i < BALL_SIZE; i++) {
balls[i].setX(rand()%BOX_SIZE*2);
balls[i].setY(rand()%BOX_SIZE*2);
balls[i].setZ(rand()%BOX_SIZE*2);
}
rotx = 0;
roty = 0;
rotz = 0;
box_x = 0;
box_y = 0;
box_z = 0;
posx = 0;
posy = 0;
posz = 100;
max = BALL_SIZE;
}
开发者ID:hypereddie,项目名称:Bouncing-Boxes,代码行数:31,代码来源:render.cpp
示例10: BASS_StreamCreateFile
float CBassAudio::GetSoundBPM ( void )
{
if ( m_fBPM == 0.0f && !m_bStream )
{
float fData = 0.0f;
// open the same file as played but for bpm decoding detection
DWORD bpmChan = BASS_StreamCreateFile ( false, m_strPath, 0, 0, BASS_STREAM_DECODE );
if ( !bpmChan )
{
bpmChan = BASS_MusicLoad ( false, m_strPath, 0, 0, BASS_MUSIC_DECODE|BASS_MUSIC_PRESCAN, 0 );
}
// detect bpm in background and return progress in GetBPM_ProgressCallback function
if ( bpmChan )
{
fData = BASS_FX_BPM_DecodeGet ( bpmChan, 0, GetLength ( ), 0, BASS_FX_FREESOURCE, NULL, NULL );
}
if ( BASS_ErrorGetCode ( ) != BASS_OK )
{
g_pCore->GetConsole ( )->Printf ( "BASS ERROR %d in BASS_FX_BPM_DecodeGet path:%s 3d:%d loop:%d", BASS_ErrorGetCode ( ), *m_strPath, m_b3D, m_bLoop );
}
else
{
m_fBPM = floor ( fData );
}
BASS_FX_BPM_BeatFree ( bpmChan );
}
return m_fBPM;
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:29,代码来源:CBassAudio.cpp
示例11: StopRecording
void StopRecording()
{
BASS_ChannelStop(rchan);
rchan=0;
{ // complete the WAVE header
DWORD len=ftell(rfp),v;
fseek(rfp,4,SEEK_SET);
v=len-8;
fwrite(&v,1,4,rfp);
fseek(rfp,40,SEEK_SET);
v=len-44;
fwrite(&v,1,4,rfp);
fclose(rfp);
}
MESS(10,WM_SETTEXT,0,L"Record");
// setup output device (using default device)
if (!BASS_Init(-1,44100,0,NULL,NULL)) {
Error(L"Can't initialize output device");
return;
}
// create a stream from the recording
if (chan=BASS_StreamCreateFile(FALSE,L"bass.wav",0,0,BASS_UNICODE))
EnableWindow(DLGITEM(11),TRUE); // enable "play" button
else
BASS_Free();
}
开发者ID:AlexanderMykulych,项目名称:Game_Dragons_Qt,代码行数:26,代码来源:rectest.c
示例12: PlayFile
// select a file to play, and play it
BOOL PlayFile()
{
BOOL ret=FALSE;
regex_t fregex;
GtkWidget *filesel; // file selector
GtkFileFilter *filter;
filesel=gtk_file_chooser_dialog_new("Open File",GTK_WINDOW(win),GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL);
filter=gtk_file_filter_new();
gtk_file_filter_set_name(filter,"Playable files");
regcomp(&fregex,"\\.(mo3|xm|mod|s3m|it|umx|mp[1-3]|ogg|wav|aif)$",REG_ICASE|REG_NOSUB|REG_EXTENDED);
gtk_file_filter_add_custom(filter,GTK_FILE_FILTER_FILENAME,FileExtensionFilter,&fregex,NULL);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filesel),filter);
filter=gtk_file_filter_new();
gtk_file_filter_set_name(filter,"All files");
gtk_file_filter_add_pattern(filter,"*");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filesel),filter);
if (gtk_dialog_run(GTK_DIALOG(filesel))==GTK_RESPONSE_ACCEPT) {
char *file=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filesel));
gtk_widget_hide(filesel);
if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_LOOP))
&& !(chan=BASS_MusicLoad(FALSE,file,0,0,BASS_MUSIC_RAMP|BASS_SAMPLE_LOOP,1))) {
Error("Can't play file");
} else {
BASS_ChannelPlay(chan,FALSE);
ret=TRUE;
}
g_free(file);
}
gtk_widget_destroy(filesel);
return ret;
}
开发者ID:AntonGerasimov,项目名称:Converter,代码行数:33,代码来源:spectrum.c
示例13: play
void play(char *file) {
if (status != 0)
stop();
stream = BASS_StreamCreateFile(FALSE, file, 0, 0, 0);
BASS_ChannelPlay(stream, 0);
status = 1;
printf("Now Playing :\n%s\n", file);
// getInfo(1); //bug: causes to crash when songs with huge titles comein :|
}
开发者ID:mevinbabuc,项目名称:OpenPlayer,代码行数:9,代码来源:main.c
示例14: BASS_Init
void Music::LoadMusic(const char *filename)
{
BOOL results;
results = BASS_Init(-1, 44100, 0, NULL, NULL);
if (results)
{
mp3Strewam = BASS_StreamCreateFile(false, filename, 0, 0, 0);
}
}
开发者ID:asmCode,项目名称:rw2014,代码行数:9,代码来源:Music.cpp
示例15: assert
// --[ Method ]---------------------------------------------------------------
//
// - Class : CSoundSystem
// - prototype : CSound* LoadSound(CInput* pInput, const std::string& strExt)
//
// - Purpose : Loads a sound, setting it ready to play.
// If succesfull, it returns a valid handle to operate
// with, otherwise it returns NULL.
//
// -----------------------------------------------------------------------------
CSound* CSoundSystem::LoadSound(CInput* pInput, const std::string& strExt)
{
if(m_bActive == false)
{
return NULL;
}
// Put it into a buffer:
pInput->SetPosition(0, CInput::SEEKFROM_START);
char* pBuffer = new char[pInput->GetLength()];
assert(pBuffer);
if(pInput->ReadRawData(pInput->GetLength(), 1, pBuffer) == 0)
{
CLogger::ErrorWindow("ERROR - CSoundSystem::LoadSound():\npInput->ReadRawData() failed");
SAFE_DELETE_A(pBuffer);
return NULL;
}
CSound* pSound = NULL;
if(IsModule(strExt))
{
HMUSIC module = BASS_MusicLoad(TRUE, pBuffer, 0, pInput->GetLength(), 0);
if(!module)
{
CLogger::ErrorWindow("ERROR - CSoundSystem::LoadSound():\nBASS_MusicLoad() failed");
return NULL;
}
CSound* pSound = new CSoundModule(module, pBuffer);
m_vecSounds.push_back(pSound);
return pSound;
}
else if(IsStream(strExt))
{
HSTREAM stream = BASS_StreamCreateFile(TRUE, pBuffer, 0, pInput->GetLength(), BASS_MP3_SETPOS);
if(!stream)
{
CLogger::ErrorWindow("ERROR - CSoundSystem::LoadSound():\nBASS_StreamCreateFile() failed");
return NULL;
}
CSound* pSound = new CSoundStream(stream, pBuffer);
m_vecSounds.push_back(pSound);
return pSound;
}
SAFE_DELETE_A(pBuffer);
CLogger::ErrorWindow("ERROR - CSoundSystem::LoadSound():\nUnknown format (%s)", strExt.data());
return NULL;
}
开发者ID:stravaganza,项目名称:sgzsourcepack,代码行数:66,代码来源:SoundSystem.cpp
示例16: stopSong
void PlaybackWidget::changeSong(QString songPath)
{
stopSong();
curchan = BASS_StreamCreateFile(false,songPath.utf16(),0,0,
BASS_SAMPLE_FLOAT | BASS_STREAM_AUTOFREE | BASS_UNICODE);
BASS_ChannelPlay(curchan,false);
cursongblength = BASS_ChannelGetLength(curchan, BASS_POS_BYTE);
cursonglength = BASS_ChannelBytes2Seconds(curchan,cursongblength);
changeState(PLAYING);
}
开发者ID:Sushisource,项目名称:wubwub,代码行数:10,代码来源:playbackwidget.cpp
示例17: ZeroMemory
HSTREAM CBassMusicEngine::LoadFile( LPCTSTR lpszFileName )
{
tagMusicInfo _Info;
ZeroMemory(&_Info,sizeof _Info);
if (!(_Info.hStream = BASS_StreamCreateFile(FALSE, lpszFileName,0,0,BASS_SAMPLE_MONO)))
{
ShowError(TEXT("不能打开该文件"));
return -1;
}
_Info.dwTime = BASS_ChannelBytes2Seconds(_Info.hStream,BASS_ChannelGetLength(_Info.hStream,BASS_POS_BYTE) );
TAG_ID3 *pTag = (TAG_ID3 *)BASS_ChannelGetTags(_Info.hStream,BASS_TAG_ID3);
if ( pTag != NULL )
{
#ifdef UNICODE
MultiByteToWideChar(CP_ACP, 0, pTag->artist, -1, _Info.szArtist, 30);
MultiByteToWideChar(CP_ACP, 0, pTag->title, -1, _Info.szTitle, 30);
if ( lstrlen(_Info.szArtist) == 0 )
{
lstrcpyn(_Info.szArtist,TEXT("未知"),CountArray(_Info.szArtist));
}
if ( lstrlen(_Info.szTitle) == 0 )
{
CString StrTitle(lpszFileName);
StrTitle = StrTitle.Right(StrTitle.GetLength()-StrTitle.ReverseFind('\\')-1);
StrTitle = StrTitle.Left(StrTitle.Find('.'));
lstrcpyn(_Info.szTitle,StrTitle,CountArray(_Info.szTitle));
}
#else
lstrcpyn(_Info.szArtist,CString(pTag->artist),CountArray(_Info.szArtist));
lstrcpyn(_Info.szTitle,CString(pTag->title),CountArray(_Info.szTitle));
#endif
}
else
{
CString StrTitle(lpszFileName);
StrTitle = StrTitle.Right(StrTitle.GetLength()-StrTitle.ReverseFind('\\')-1);
StrTitle = StrTitle.Left(StrTitle.Find('.'));
lstrcpyn(_Info.szArtist,TEXT("未知"),CountArray(_Info.szArtist));
lstrcpyn(_Info.szTitle,StrTitle,CountArray(_Info.szTitle));
}
m_MusicEngineMap.insert(pair<HSTREAM,tagMusicInfo>(_Info.hStream,_Info));
//Play(_Info.hStream);
return _Info.hStream;
}
开发者ID:3rdexp,项目名称:soui,代码行数:55,代码来源:BassMusic.cpp
示例18: OpenEventHandler
pascal OSStatus OpenEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
{
NavDialogRef fileDialog;
NavDialogCreationOptions fo;
NavGetDefaultDialogCreationOptions(&fo);
fo.optionFlags=0;
fo.parentWindow=win;
NavCreateChooseFileDialog(&fo,NULL,NULL,NULL,NULL,NULL,&fileDialog);
// if someone wants to somehow get the file selector to filter like in the Windows example, that'd be nice ;)
if (!NavDialogRun(fileDialog)) {
NavReplyRecord r;
if (!NavDialogGetReply(fileDialog,&r)) {
AEKeyword k;
FSRef fr;
if (!AEGetNthPtr(&r.selection,1,typeFSRef,&k,NULL,&fr,sizeof(fr),NULL)) {
char file[256];
FSRefMakePath(&fr,(BYTE*)file,sizeof(file));
BASS_StreamFree(chan); // free old stream before opening new
if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_LOOP|BASS_SAMPLE_FLOAT))) {
SetControlTitleWithCFString(inUserData,CFSTR("click here to open a file..."));
{
ControlRef cref=GetControl(11);
SetControlData(cref,kControlNoPart,kControlStaticTextTextTag,0,"");
DrawOneControl(cref);
}
SetControl32BitMaximum(GetControl(12),0);
Error("Can't play the file");
} else {
CFStringRef cs=CFStringCreateWithCString(0,file,kCFStringEncodingUTF8);
SetControlTitleWithCFString(inUserData,cs);
CFRelease(cs);
{ // display the file type and length
QWORD bytes=BASS_ChannelGetLength(chan,BASS_POS_BYTE);
DWORD time=BASS_ChannelBytes2Seconds(chan,bytes);
BASS_CHANNELINFO info;
BASS_ChannelGetInfo(chan,&info);
sprintf(file,"channel type = %x (%s)\nlength = %llu (%u:%02u)",
info.ctype,GetCTypeString(info.ctype,info.plugin),bytes,time/60,time%60);
{
ControlRef cref=GetControl(11);
SetControlData(cref,kControlNoPart,kControlStaticTextTextTag,strlen(file),file);
DrawOneControl(cref);
}
SetControl32BitMaximum(GetControl(12),time); // update scroller range
}
BASS_ChannelPlay(chan,FALSE);
}
}
NavDisposeReply(&r);
}
}
NavDialogDispose(fileDialog);
return noErr;
}
开发者ID:bagnz0r,项目名称:ichigo-audio,代码行数:54,代码来源:plugins.c
示例19: strcpy
//-----------------------------------------------------------------------------
bool LLFFTSound::loadSound(const char* filename, const char* speech, bool looping)
{
// set speech contents
strcpy(m_Speech, speech);
#ifdef _WINDOWS
// initialize BASS
if (!bBassInit)
{
if (!BASS_Init(-1,44100,0,0,NULL)) {
//Error("Can't initialize device");
return false;
}
bBassInit = true;
}
if (looping)
{
if (!(m_dChannel=BASS_StreamCreateFile(FALSE,filename,0,0,BASS_SAMPLE_LOOP))
&& !(m_dChannel=BASS_MusicLoad(FALSE,filename,0,0,BASS_MUSIC_RAMP|BASS_SAMPLE_LOOP,0))) {
return false; // Can't load the file
}
}
else
{
if (!(m_dChannel=BASS_StreamCreateFile(FALSE,filename,0,0,0))
&& !(m_dChannel=BASS_MusicLoad(FALSE,filename,0,0,BASS_MUSIC_RAMP|BASS_SAMPLE_LOOP,0))) {
return false; // Can't load the file
}
}
m_bInitialized = true;
return true;
#else
return false;
#endif
}
开发者ID:joysword,项目名称:LifeLike,代码行数:42,代码来源:LLFFTSound.cpp
示例20: fname
AudioClip::AudioClip(std::string filename)
{
pan = 0.0f;
volume = 1.0f;
pitch = 0.0f;
loop = false;
play_once = false;
oshot = false;
std::wstring fname(filename.begin(), filename.end());
hm = BASS_StreamCreateFile(FALSE, fname.c_str(), 0, 0, BASS_STREAM_DECODE);
hm = BASS_FX_TempoCreate(hm, BASS_FX_FREESOURCE);
}
开发者ID:jozadaquebatista,项目名称:DQBIX-Game-Engine,代码行数:13,代码来源:audio.cpp
注:本文中的BASS_StreamCreateFile函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论