コード例 #1
0
void QSoundEffectPrivate::timerEvent(QTimerEvent *event)
{
    if (m_runningCount > 0)
        playSample();

    killTimer(event->timerId());
}
コード例 #2
0
ファイル: sound.cpp プロジェクト: St0rmcrow/scummvm
void Sound::engine() {
	// first of all, add any random sfx to the queue...
	for (uint16 cnt = 0; cnt < TOTAL_FX_PER_ROOM; cnt++) {
		uint16 fxNo = _roomsFixedFx[Logic::_scriptVars[SCREEN]][cnt];
		if (fxNo) {
			if (_fxList[fxNo].type == FX_RANDOM) {
				if (_rnd.getRandomNumber(_fxList[fxNo].delay) == 0)
					addToQueue(fxNo);
			}
		} else
			break;
	}
	// now process the queue
	for (uint8 cnt2 = 0; cnt2 < _endOfQueue; cnt2++) {
		if (_fxQueue[cnt2].delay > 0) {
			_fxQueue[cnt2].delay--;
			if (_fxQueue[cnt2].delay == 0)
				playSample(&_fxQueue[cnt2]);
		} else {
			if (!_mixer->isSoundHandleActive(_fxQueue[cnt2].handle)) { // sound finished
				_resMan->resClose(_fxList[_fxQueue[cnt2].id].sampleId);
				if (cnt2 != _endOfQueue-1)
					_fxQueue[cnt2] = _fxQueue[_endOfQueue - 1];
				_endOfQueue--;
			}
		}
	}
}
コード例 #3
0
ファイル: cube.cpp プロジェクト: honnet/SifteoGame
// called by touching the screen (see main.c)
void Cube::restart() {
    lifeCounter = 100;
    playSample(StartSND);
    initDisplay();
    if (IDcounter++ == 0)
        AudioChannel(0).resume(); // loop
}
コード例 #4
0
void SamplePlayer::playCurrentSampleFromOffset(pp_uint32 offset, pp_uint32 note)
{
	SampleEditor* sampleEditor = moduleEditor.getSampleEditor();

	if (offset != -1)
	{
		playSample(*sampleEditor->getSample(),
				   note,
				   offset,
				   sampleEditor->getSampleLen());
	}
}
コード例 #5
0
void SamplePlayer::playCurrentSampleSelectionRange(pp_uint32 note)
{
	SampleEditor* sampleEditor = moduleEditor.getSampleEditor();
	
	if (sampleEditor->getLogicalSelectionStart() != -1 &&
		sampleEditor->getLogicalSelectionEnd() != -1)
	{
		playSample(*sampleEditor->getSample(), 
				   note, 
				   sampleEditor->getLogicalSelectionStart(), 
				   sampleEditor->getLogicalSelectionEnd());
	}
	
}
コード例 #6
0
ファイル: cube.cpp プロジェクト: honnet/SifteoGame
// (dis)play explosions and damages on Conan
void Cube::displayDamages() {
    bool displayDoh = false;
    const uint8_t limit = 3*exploDuration/4;

    for (uint8_t d=0; d<dot_n; d++) {
        if (dots[d].exp) {                              // is it exploded ?
            --dots[d].exp;
            if (dots[d].exp == exploDuration-1) {
                playSample(*ExploSND[r.chance(0.5)]);   // play an explosion sound
                if (dots[d].bnd)
                    displayDoh = true;                  // will display D'oh !
            }

            if (dots[d].exp > limit)                    // explosion animation?
                vid.sprites[d].setImage(*ExplosionIMG[dots[d].exp & 0x1]);
            else if (dots[d].bnd && dots[d].exp == limit)
                vid.sprites[d].setImage(BandIMG);       // display band aid
            else if (dots[d].exp == 0 || !dots[d].bnd) {
                vid.sprites[d].hide();                  // end of damages
                vid.bg0.image(vec(10,1), DohIMG.tileSize(),
                              ConanIMG, vec(10,1));
                dots[d].exp = 0;
                dots[d].bnd = 0;
            }
        }
    }

    if (displayDoh) {
        vid.bg0.image(vec(10,1), DohIMG);
        // remove a band aid each time 10% life is lost
        UInt2 size = {10-lifeCounter/10, 1};
        vid.bg0.fill(vec(3,15), size, whiteTile);
        playSample(*DohSND[r.chance(.5)]); // play one of the D'oh! sounds
        System::paint();
    }
}
コード例 #7
0
void QSoundEffectPrivate::play()
{
    if (m_retry) {
        m_retry = false;
        setSource(m_source);
        return;
    }

    if (!m_sampleLoaded) {
        m_playQueued = true;
        return;
    }

    m_runningCount += m_loopCount;

    playSample();
}
コード例 #8
0
ファイル: cube.cpp プロジェクト: honnet/SifteoGame
// Game Over: Conan The Simpsonian is dead !
void Cube::win() {
    playSample(WinSND);
    if (--IDcounter == 0)
        AudioChannel(0).pause(); // loop

    reset();
    vid.bg0.fill(vec(0,0), LCD_size/8, whiteTile);
    System::paint();
    vid.bg0.image(vec(2,2), EndIMG);
    System::paint();

    String<16> message;
    vid.initMode(BG0_ROM);
    message << "Touch: restart";
    vid.bg0rom.text(vec(1,0), message);
    vid.setWindow(4, 8);
    System::paint();
}
コード例 #9
0
EFI_STATUS
EFIAPI
UefiMain (
		IN EFI_HANDLE        ImageHandle,
		IN EFI_SYSTEM_TABLE  *SystemTable
	 )
{    
	EFI_STATUS  Status = EFI_SUCCESS;
	//UINTN       Index;
	//UINT32      CurRow=0, CurCol=0;    

	//UINT32 CmdLen = 0;
	// init CPP and global Constructor
    //((unsigned short*)(wavHeader->wavData));

    {
        UINTN Index;
        EFI_GUID gEfiAudioProtocolGUID =        EFI_AUDIO_PROTOCOL_GUID; 
        
        Status = gBS->LocateProtocol(
                &gEfiAudioProtocolGUID ,
                NULL,
                (VOID **)&Audio);
        if (EFI_ERROR(Status)) {
            Print(L"LocateProtocol %r\n", Status);
            return Status;
        }
        {
            INT32 v = 200;
            Audio->Volume(Audio, 0,  &v);
        }

        if(filename == NULL){
            playSample();
        }else{
            playafile(filename);
        }
        (void) Index;
        //gBS->WaitForEvent(1, &(Audio->WaitForEndEvent), &Index);
        Print(L"press any key to exit......\n");
        gBS->WaitForEvent(1, &( gST->ConIn->WaitForKey), &Index);
        return Status;
    }
}
コード例 #10
0
ファイル: Audio.cpp プロジェクト: BackupTheBerlios/sotu-svn
//----------------------------------------------------------------------------
void Audio::updateVolume( void)
{
    int newVolume;

    float musicVolume = 0.8;
    ConfigS::instance()->getFloat( "musicVolume", musicVolume);
    newVolume = (int)(MIX_MAX_VOLUME * musicVolume);
    if (_musicVolume != musicVolume)
    {
        _musicVolume = musicVolume;
        Mix_VolumeMusic( newVolume);
    }

    float effectsVolume = 0.8;
    ConfigS::instance()->getFloat( "effectsVolume", effectsVolume);
    newVolume = (int)(MIX_MAX_VOLUME * effectsVolume);
    if (_effectsVolume != effectsVolume)
    {
        _effectsVolume = effectsVolume;
        Mix_Volume( -1, newVolume);
        playSample( "sounds/beep.wav");
    }
}
コード例 #11
0
void SamplePlayer::playCurrentSample(pp_uint32 note)
{
	playSample(*moduleEditor.getSampleEditor()->getSample(), note);
}
コード例 #12
0
void SamplePlayer::playSample(pp_int32 insIndex, pp_uint32 note)
{
	const mp_ubyte* nbu = moduleEditor.getSampleTable(insIndex);
	pp_int32 smpIndex = nbu[note];
	playSample(insIndex, smpIndex, note);
}
コード例 #13
0
void SamplePlayer::playSample(pp_int32 insIndex, pp_int32 smpIndex, pp_uint32 note)
{
	playSample(*moduleEditor.getSampleInfo(insIndex, smpIndex), note);
}
コード例 #14
0
ファイル: menu.cpp プロジェクト: jbradish/nikwi
void MenuScreen::handleEvent(SDL_Event &e)
{
	if (e.type != SDL_KEYDOWN)
		return;
		
	if (pwdMode)
	{
		if (e.key.keysym.sym >= SDLK_a && e.key.keysym.sym <= SDLK_z)
		{
			if (pwdLen == 6)
			{
				playSample(findSample(makeCode("slct")));
				return;
			}
			playSample(findSample(makeCode("tick")));
			pwd[pwdLen++] = 'a'+(e.key.keysym.sym-SDLK_a);
			return;
		}
		if (e.key.keysym.sym == SDLK_BACKSPACE)
		{
			if (!pwdLen)
			{
				playSample(findSample(makeCode("slct")));
				return;
			}
			playSample(findSample(makeCode("tick")));
			pwdLen--;
			return;
		}
		if (e.key.keysym.sym == SDLK_RETURN)
		{
			playSample(findSample(makeCode("tick")));
			if (pwdLen == 6)
			{
				pwd[6] = 0;
				game->newGame(pwd);
				e.key.keysym.sym = SDLK_a;
				game->activate();
			}
			pwdMode = false;
			return;
		}
		if (e.key.keysym.sym == SDLK_ESCAPE)
			pwdMode = false;
		return;
	}
	
	switch (e.key.keysym.sym)
	{
		case SDLK_DOWN:
			if (opt == 3)
				opt = 0;
			else
				opt++;
			playSample(findSample(makeCode("slct")));
			break;
		case SDLK_UP:
			if (opt)
				opt--;
			else
				opt = 3;
			playSample(findSample(makeCode("slct")));
			break;
		case SDLK_SPACE:
		case SDLK_RETURN:
		{
			playSample(findSample(makeCode("tick")));
			switch (opt)
			{
				case 0:
					game->newGame(); 
					game->activate();
					break;
				case 1:
					pwdLen = 0;
					pwdMode = true;
					break;
				case 2:
					imageScreen->showImage(this,
						"data/objects/credits.ut");
					break;
				case 3:
					running = false;
					break;
			}
			break;
		}
		case SDLK_ESCAPE:
			if (game->playing)
				game->activate();
			break;
		default:;
	}
}
コード例 #15
0
bool BrainSoundFMODEX::playMusic()
{
	return playSample(m_music_id);
}
コード例 #16
0
void editModelItem(ModelItem *model_item)
{
  int width = 65, height = 22, i, j;             /***** ncurses related variables */
  WINDOW *itemscr = popupWindow (width, height);

  int top = 0, current = 0;   /***** menu selection related variables */
  int max_view = 6;

  int input_field_width = 40; /***** width of string input field */

  int request_finish = 0;     /***** request_finish = 1 breaks the main while loop */

  while (!request_finish)
  {
    wattrset (itemscr, color_term ? COLOR_PAIR(2) | A_BOLD : A_NORMAL);  /***** set bg color of the dialog */

    /*****
     * draw a box around the dialog window
     * and empty it.
     *****/
    werase (itemscr);
    box (itemscr, 0, 0);
    for (i = 1; i < width-1; i++)
      for (j = 1; j < height-1; j++)
	mvwaddch(itemscr, j, i, ' ');

    /***** dialog header */

    mvwaddstr(itemscr, 1, 2, "Edit Speaker Model Item");
    mvwaddseparator(itemscr, 2, width);

    /***** display help at the bottom */

    mvwaddseparator(itemscr, height-4, width);
    mvwaddstr(itemscr, height-3, 2, "r = record sample, d = delete sample, enter = play sample");
    mvwaddstr(itemscr, height-2, 2, "b = back to model menu, l = edit label, c = edit command");

    /***** display information about current speaker item */

    mvwaddstr(itemscr, 4, 2, "Label   :");
    mvwaddnstr(itemscr, 4, 12, model_item->label, input_field_width);
    mvwaddstr(itemscr, 5, 2, "Command :");
    mvwaddnstr(itemscr, 5, 12, model_item->command, input_field_width);

    mvwaddstr(itemscr, 7, 2, "Number of samples:");
    mvwaddint(itemscr, 7, 21, model_item->number_of_samples);

    /***** show sample utterances in a list. */

    mvwaddstr(itemscr, 9, 4, "ID"); /***** header */
    for (i = 0; i < 28; i++)
      mvwaddch(itemscr,10, 3+i, ACS_HLINE);

    /***** list items */

    for (i = 0; i < MIN2(model_item->number_of_samples, max_view); i++)
    {
      setHighlight(itemscr, active, i == current);
      mvwaddstr(itemscr,11+i,  3, "                            ");
      mvwaddstr(itemscr,11+i,  4, getModelItemSample(model_item, top+i)->id);
    }
    wattroff(itemscr, A_REVERSE);

    /***** up/down arrows indicate that not all items can be displayed */

    if (top > 0)
    {
      mvwaddch(itemscr,11, 2, ACS_UARROW);
      mvwaddch(itemscr,11+1, 2, ACS_VLINE);
    }
    if (model_item->number_of_samples > max_view && top+max_view <= model_item->number_of_samples-1)
    {
      mvwaddch(itemscr,11+max_view-2, 2, ACS_VLINE);
      mvwaddch(itemscr,11+max_view-1, 2, ACS_DARROW);
    }

    wmove(itemscr, 1,26); /***** move cursor to a convenient location */
    wrefresh(itemscr);    /***** refresh dialog window */

    /* process the command keystroke */

    switch(getch())
    {
    case KEY_UP: /***** cursor up */
      if (top+current > 0)
      {
	if (current > 0)
	 current--;
	else
	  top--;
      }
      break;
    case KEY_DOWN: /***** cursor down */
      if (top+current < model_item->number_of_samples-1)
      {
	if (current < max_view-1)
	 current++;
	else
	  top++;
      }
      break;
    case 'b':      /***** leave menu */
      request_finish = 1;
      break;
    case ENTER:    /***** play selected utterance */
      if (model_item->number_of_samples > 0)
      {
	int width = 42, height = 8, i, j;                  /* ncurses related variables */
	WINDOW *playbackscr = popupWindow (width, height);

	wattrset (playbackscr, color_term ? COLOR_PAIR(2) | A_BOLD : A_NORMAL); /***** set bg color of the dialog */
	/*****
	 * draw a box around the dialog window
	 * and empty it.
	 *****/
	werase (playbackscr);
	box (playbackscr, 0, 0);
	for (i = 1; i < width-1; i++)
	  for (j = 1; j < height-1; j++)
	    mvwaddch(playbackscr, j, i, ' ');

	/***** dialog header */
	
	mvwaddstr(playbackscr, 1, 2, "Playback");
	mvwaddseparator(playbackscr, 2, width);

	/***** play wave if present */
	
	if (getModelItemSample(model_item, top+current)->has_wav)
	{
	  /***** dialog message */
	
	  mvwaddstr(playbackscr, 3, 2,"Utterance is being played ...      ");
	  /* mvwaddstrcntr(playbackscr, 6, width, "Press any key to cancel ..."); */
	
	  wmove(playbackscr, 1, 11); /***** move cursor to an appropriate location */
	  wrefresh (playbackscr);    /***** refresh dialog window */

	  /***** if play fails or was cancelled ....*/
	
	  if (playSample(getModelItemSample(model_item, top+current)) != AUDIO_OK)
	  {
	    /***** display information */
	
	    mvwaddstr(playbackscr, 1, 2, "Warning!    ");
	    mvwaddstr(playbackscr, 3, 2,"Either playback has been cancelled  ");
	    mvwaddstr(playbackscr, 4, 2,"or wave couldn't be sent to your    ");
	    mvwaddstr(playbackscr, 5, 2,"soundcard !                         ");
	    mvwaddstrcntr(playbackscr, 6, width, "Press any key to continue ...");

	    wmove(playbackscr, 1, 11); /***** move cursor to an appropriate location */
	    wrefresh (playbackscr);    /***** refresh dialog window */
	    getch();                   /***** wait for keyboard input */
	  }
	}
	else /***** no wave data present! */
	{
	  mvwaddstr(playbackscr, 3, 2,"Utterance can't be played! No wave  ");
	  mvwaddstr(playbackscr, 4, 2,"data available! Note: KvoiceControl ");
	  mvwaddstr(playbackscr, 5, 2,"did NOT save the original wave data!");
	  mvwaddstrcntr(playbackscr, 6, width, "Press any key to cancel ...");
	
	  wmove(playbackscr, 1, 11); /***** move cursor to an appropriate location */
	  wrefresh (playbackscr);    /***** refresh dialog window */
	  getch();                   /***** wait for keyboard input */
	}
	
	delwin(playbackscr);   /***** delete ncurses dialog window */
      }
      break;
    case 'r':   /***** record sample utterance */
      {
	int width = 42, height = 8, i, j;   /***** ncurses related variables */
	WINDOW *recordscr = popupWindow (width, height);

	ModelItemSample *new_sample; /***** temporary pointer to new utterance */
	
	wattrset (recordscr, color_term ? COLOR_PAIR(2) | A_BOLD : A_NORMAL); /***** set bg color of the dialog */

	/*****
	 * draw a box around the dialog window
	 * and empty it.
	 *****/
	werase (recordscr);
	box (recordscr, 0, 0);
	for (i = 1; i < width-1; i++)
	  for (j = 1; j < height-1; j++)
	    mvwaddch(recordscr, j, i, ' ');

	/***** dialog header */
	
	mvwaddstr(recordscr, 1, 2, "Recording");
	mvwaddseparator(recordscr, 2, width);

	/***** dialog message */
	
	mvwaddstr(recordscr, 3, 2,"Utterance is recorded automatically!");
	mvwaddstr(recordscr, 4, 2,"Please say what you want to say ...");
	mvwaddstrcntr(recordscr, 6, width, "Press any key to cancel ...");
	
	wmove(recordscr, 1, 12); /***** move cursor to a convenient location */
	wrefresh (recordscr);    /***** refresh dialog screen */
	
	new_sample = recordSample(); /***** auto record a sample utterance */
	
	if (new_sample != NULL) /***** if the recording was successful ... */
	{
	  appendModelItemSample(model_item, new_sample); /***** add the sample to the model */

	  /***** set cursor to be over new sample utterance */
	
	  current = model_item->number_of_samples-1 - top;
	  while (current > max_view-1)
	  {
	    current--;
	    top++;
	  }
	}
	else /***** recording has failed or was cancelled */
	{
	  /***** dialog message */
	
	  mvwaddstr(recordscr, 1, 2, "Cancel!    ");
	  mvwaddstr(recordscr, 3, 2,"Nothing has been recorded! Either   ");
	  mvwaddstr(recordscr, 4, 2,"you cancelled or no data could be   ");
	  mvwaddstr(recordscr, 5, 2,"recorded !                          ");
	  mvwaddstrcntr(recordscr, 6, width, "Press any key to continue ...");

	  wmove(recordscr, 1, 10); /***** move cursor to a convenient location */
	  wrefresh (recordscr);    /***** refresh dialog screen   */
	  getch();                 /***** wait for keyboard input */
	}
	
	delwin(recordscr);   /***** delete ncurses dialog window */
      }
      break;
    case 'l': /***** edit label */
      {
	/*****
	 * use wstringInput to edit the label of the current utterance
	 * if the label has changed, switch 'modified' to 1
	 *****/
	char tmp_string[1000];
	strcpy(tmp_string, model_item->label);
	free(model_item->label);
	model_item->label = wstringInput(itemscr, 4, 12, 255, input_field_width, tmp_string);
	if (strcmp(tmp_string, model_item->label) != 0)
	  modified = 1;
      }
      break;
    case 'c': /***** edit command */
      {
	/*****
	 * use wstringInput to edit the commandd of the current utterance
	 * if the command has changed, switch 'modified' to 1
	 *****/
	char tmp_string[1000];
	strcpy(tmp_string, model_item->command);
	free(model_item->command);
	model_item->command = wstringInput(itemscr, 5, 12, 255, input_field_width, tmp_string);
	if (strcmp(tmp_string, model_item->command) != 0)
	  modified = 1;
      }
      break;
    case 'd':
      /*****
       * delete currently selected sample utterance from model item
       * and switch 'modified' to 1
       *****/
      deleteModelItemSample(model_item, top+current);
      modified = 1;

      /***** set cursor to a valid value */
	
      if (top+current == model_item->number_of_samples)
      {
	if (top > 0)
	  top--;
	else if (current > 0)
	  current--;
      }
      break;
    }
  }
}