void ORiffPlay::play(PSZ waveFileName, ORiffPlay::PlayType playType) { waveFile << waveFileName; playWave(playType); }
void ORiffPlay::play(ULONG soundID, ORiffPlay::RiffType resType, ORiffPlay::PlayType playType) { waveID = soundID; waveType = resType; playWave(playType); }
int QSoundManager::playSound(CWaveFile &waveFile, CProximity &prox) { int channel = -1; uint flags = QMIX_CLEARQUEUE; if (prox._priorSoundHandle >= 1) { // This sound should only be started after a prior one finishes, // so scan the slots for the specified sound for (uint idx = 0; idx < _slots.size(); ++idx) { if (_slots[idx]._handle == prox._priorSoundHandle) { channel = _slots[idx]._channel; flags = QMIX_QUEUEWAVE; break; } } } if (channel >= 0 || (channel = resetChannel(prox._channel)) != -1) { return playWave(&waveFile, channel, flags, prox); } return 0; }
int ONScripter::playSound(const char *filename, int format, bool loop_flag, int channel) { if ( !audio_open_flag ) return SOUND_NONE; long length = script_h.cBR->getFileLength( filename ); if (length == 0) return SOUND_NONE; unsigned char *buffer; if (format & SOUND_MUSIC && length == music_buffer_length && music_buffer ){ buffer = music_buffer; } else{ buffer = new(std::nothrow) unsigned char[length]; if (buffer == NULL){ fprintf( stderr, "failed to load [%s] because file size [%lu] is too large.\n", filename, length); return SOUND_NONE; } script_h.cBR->getFile( filename, buffer ); } if (format & SOUND_MUSIC){ music_info = Mix_LoadMUS_RW( SDL_RWFromMem( buffer, length ) ); Mix_VolumeMusic( music_volume ); Mix_HookMusicFinished( musicFinishCallback ); if ( Mix_PlayMusic( music_info, music_play_loop_flag?-1:0 ) == 0 ){ music_buffer = buffer; music_buffer_length = length; return SOUND_MUSIC; } } if (format & SOUND_CHUNK){ Mix_Chunk *chunk = Mix_LoadWAV_RW(SDL_RWFromMem(buffer, length), 1); if (playWave(chunk, format, loop_flag, channel) == 0){ delete[] buffer; return SOUND_CHUNK; } } /* check WMA */ if ( buffer[0] == 0x30 && buffer[1] == 0x26 && buffer[2] == 0xb2 && buffer[3] == 0x75 ){ delete[] buffer; return SOUND_OTHER; } if (format & SOUND_MIDI){ FILE *fp; if ( (fp = fopen(TMP_MUSIC_FILE, "wb")) == NULL){ fprintf(stderr, "can't open temporaly MIDI file %s\n", TMP_MUSIC_FILE); } else{ fwrite(buffer, 1, length, fp); fclose( fp ); ext_music_play_once_flag = !loop_flag; if (playMIDI(loop_flag) == 0){ delete[] buffer; return SOUND_MIDI; } } } delete[] buffer; return SOUND_OTHER; }
void GBMJDesktopController::gameTraceView( const GeneralGameTrace2Head *gameTrace ) { switch(gameTrace->chType) { case MAHJONG_GAMETRACE_RESET : //case MAHJONG_GAMETRACE_DEAL : case MAHJONG_GAMETRACE_INIT : { // printf("trace=%02x seat=%d buflen=%d\n",gameTrace->chType,gameTrace->chSite,gameTrace->chBufLen); RenewWall(); RepaintPlayerCards(gameTrace->chSite); break; } case MAHJONG_GAMETRACE_OUT : { djDebug() << "MAHJONG_GAMETRACE_OUT"; RepaintPlayerCards(gameTrace->chSite); RepaintPoolCards(m_lastThrowSeat); RepaintPoolCards(gameTrace->chSite); quint8 seat = gameTrace->chSite; quint8 card = gameTrace->chBuf[0]; djDebug() << "seat =" << seat << "card =" << card; QString wavName = QString("%1.wav").arg(card,2,16,QChar::fromLatin1('0')); playWave(wavName); if ( gameTrace->chSite == panelController()->seatId() ) RepaintView1Flowers(gameTrace->chSite); break; } case MAHJONG_GAMETRACE_PICKUP : case MAHJONG_GAMETRACE_DRAW : { if(GetSeatPrivate(gameTrace->chSite) && gameTrace->chType == MAHJONG_GAMETRACE_DRAW) break; RepaintPlayerCards(gameTrace->chSite); RenewWall(); /* if ( MAHJONG_ISFLOWERCARD( gameTrace->chBuf[0] ) && !c_MahjongPanel->isLookingOn()) {//自动补花 char ch = gameTrace->chBuf[0]; SendGameTrace(MAHJONG_GAMETRACE_GANGFLOWER,&ch,1,NULL); }*///改在gameWaitä¸è‡ªåŠ¨è¡¥èŠ? break; } case MAHJONG_GAMETRACE_WALLSTART : { RepaintWallCards(); break; } case MAHJONG_GAMETRACE_EATCOLLISION : { djDebug() << "MAHJONG_GAMETRACE_EATCOLLISION" << gameTrace->chBuf[0]; if(gameTrace->chBuf[0] == gameTrace->chBuf[1]) { playWave("peng.wav"); } else { playWave("chi.wav"); } RepaintPlayerCards(gameTrace->chSite); RepaintPoolCards(m_lastThrowSeat); break; } case MAHJONG_GAMETRACE_GANGFLOWER : { djDebug() << "MAHJONG_GAMETRACE_GANGFLOWER"; quint8 mjcard = gameTrace->chBuf[0]; djDebug() << "mjcard = " << hex << mjcard; if ( MAHJONG_ISFLOWERCARD( mjcard ) ) { playWave("bu.wav"); RepaintPlayerFlowers(gameTrace->chSite); } else { playWave("gang.wav"); RepaintPlayerCards(gameTrace->chSite); RepaintPoolCards(m_lastThrowSeat); if ( !MAHJONG_ISDIY(mjcard) ) { djDebug() << "minggang"; //ming gang,check qiang gang hu m_lastMGangCard = MAHJONG_CARD(mjcard); } } break; } case MAHJONG_GAMETRACE_TING : { RepaintPlayerCards(gameTrace->chSite); break; } case MAHJONG_GAMETRACE_HU : { //Hu(gameTrace->chSite,ptrace->chBuf,gameTrace->chBufLen); playWave("hu.wav"); DisplayHu(gameTrace->chSite,gameTrace->chBuf,gameTrace->chBufLen); break; } } }
int playWAVEFile(const char *lpszWAVEFileName) { #if 1 return 0; #else static init = 0; static HWND hwStopper; static wavc_t *root = NULL; wavc_t **node; HANDLE hfile; HMMIO hm; MMIOINFO mi; DWORD read; if(!init){ WNDCLASS wc = { 0, /* UINT style; */ SoundStopper, /*WNDPROC lpfnWndProc; */ 0, /*int cbClsExtra; */ 0, /*int cbWndExtra; */ NULL, /*HINSTANCE hInstance; */ NULL, /*HICON hIcon; */ NULL, /*HCURSOR hCursor; */ NULL, /*HBRUSH hbrBackground; */ NULL, /*LPCTSTR lpszMenuName; */ "SoundStopperClass", /*LPCTSTR lpszClassName; */ }; ATOM atom; #if 0 IDirectSound *ds; DirectSoundCreate(NULL, &ds, NULL); #endif /* ds->CreateSoundBuffer(*/ wc.hInstance = (HINSTANCE)GetModuleHandle(NULL); if(!(atom = RegisterClass(&wc)) || !(hwStopper = CreateWindow((LPCTSTR)atom, "SoundStopper", 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL))){ return 1; } init = 1; } for(node = &root; *node;){ int res; res = strncmp((*node)->fname, lpszWAVEFileName, sizeof (*node)->fname); if(res < 0) node = &(*node)->hi; else if(0 < res) node = &(*node)->lo; else break; } if(!*node){ DWORD data; FILE *fp; /* hfile = CreateFile(lpszWAVEFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); ReadFile(hfile, &head, sizeof head, &read, NULL); if(!memcmp(head.ckid, "RIFF", sizeof head.ckid) && !memcmp(head.fccType, "WAVE", sizeof head.fccType) && !memcmp(head.fmtType, "fmt ", sizeof head.fmtType)){ DWORD data; ReadFile(hfile, &data, sizeof data, &read, NULL); if(!memcmp(&data, "data", sizeof data)) WriteWaveData(&head, hfile, hwStopper); } CloseHandle(hfile);*/ if(!(*node = cacheWaveData(lpszWAVEFileName))){ return 0; } strncpy((*node)->fname, lpszWAVEFileName, sizeof(*node)->fname); (*node)->hi = (*node)->lo = NULL; } playWave(*node, hwStopper); #endif }