int main(void)
{
   /*建立audio矩陣來存放要用的檔案*/
   Audio audio[5];
   
   /* 讀入5個音效檔 */ 
   openAudioFile("DR220A_CH.wav", &audio[0]);
   openAudioFile("DR220A_SD.wav", &audio[1]);
   openAudioFile("DR220A_HT.wav", &audio[2]);
   openAudioFile("DR220A_CCY.wav", &audio[3]);
   openAudioFile("DR220A_BD.wav", &audio[4]);

                  /* 播放對應的音效 */ 
                  playAudio(&audio[0]);
                  Sleep(1000);            
                  /* 播放對應的音效 */ 
                  playAudio(&audio[1]);
                  Sleep(1000);
                  /* 播放對應的音效 */ 
                  playAudio(&audio[2]);
                  Sleep(1000);
                  /* 播放對應的音效 */ 
                  playAudio(&audio[3]);
                  Sleep(1000);
                  /* 播放對應的音效 */ 
                  playAudio(&audio[4]);
                  Sleep(1000);
      
}
示例#2
0
文件: main.c 项目: island-org/island
void draw()
{
    background(gray(122));
    if (Soloud_getActiveVoiceCount(soloud) > 0)
    {
        float * v = Soloud_calcFFT(soloud);
        int p = (int)(v[10] * 30);
        rect(10, 10, p * 10, 30);
    }

    if (keyReleased)
    {
        char sentence[20];
        sprintf(sentence, "%c", key);
        destroyAudio(keySound);
        keySound = loadSpeech(sentence);
        playAudio(keySound);
    }

    textFont(font);
    textAlign(NVG_ALIGN_LEFT);
    textSize(30);
    textLeading(5);
    text(sentence, 10, 100);
}
示例#3
0
void MainWindow::showSongsContextMenu(QPoint point)
{
    QTreeView *songs = (QTreeView*)ui->tvSongs;
    if(songs->indexAt(point).isValid()) {
        QList<QAction *> actions;

        QAction *action = new QAction(songs);
        action->setText(tr("Play"));
        connect(action, SIGNAL(triggered()), this, SLOT(playAudio()));
        actions.append(action);

        action = new QAction(songs);
        action->setText(tr("Delete"));
        connect(action, SIGNAL(triggered()), this, SLOT(deleteAudio()));
        actions.append(action);

        action = new QAction(songs);
        action->setSeparator(true);
        actions.append(action);

        QList<Playlist> pls = dp->getPlaylists();
        int n = pls.count();
        QSignalMapper* signalMapper = new QSignalMapper (this);
        for( int i=0; i<n; i++ )
        {
            action = new QAction(songs);
            action->setText("Add to " + pls[i].title);
            connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
            signalMapper->setMapping (action, pls[i].id) ;
            actions.append(action);
        }
        connect (signalMapper, SIGNAL(mapped(int)), this, SLOT(addAudioToPlaylist(int)));
        QMenu::exec(actions, songs->mapToGlobal(point));
    }
/**
* @brief Playback AudioSample_t's in samples
*
* @param samples An std::vector of AudioSample_t to be played back
*/
void AlsaPlayback::playAudio(const std::vector<AudioSample_t> & samples)
{
	if(samples.size() > 0)
	{
		playAudio(&samples[0], samples.size());
	}
}
示例#5
0
		void Sound::Play()
		{
			if (_sound)
			{
				playAudio(_sound);
			}
		}
/*=============================
void coolDownMode

inputs: none
returns: n/a

Creates a loop that checks to see if mana
is at the minimum value needed to exit cool
down mode (MIN_MANA). If it is, the loop
exits and the method is finished. It does
not need to do anything inside the loop
because the overflow ISR will automatically
replenish mana.

Written by: Katie Hobble
=================================*/
void coolDownMode() {
    //Reset manaCount to ensure we are starting from the beginning
    manaCount = 0;
    //Play audio and display visual for cool down mode
    LCDdisplay(ice, 0);
    playAudio(cooldown, 0);

    //This will check to see if mana is at the minimum
    //value it needs to be to exit cool down mode
    while(mana < MIN_MANA) {
        //Do nothing, let timer overflow do its thing
        _delay_ms(8000);
        //Clear the LCD display
        LCDdisplay(10,0);

    }//end while

    //Turn off sound (in case the cooldown sound is trying to loop)
    PORTD = 0xFF;
    //Because IR receive doesn't work, we are going to decrement health every time cooldown mode is entered
    //decrement health
    health--;

    //If health has reached zero, just turn off interrupts
    //Otherwise, display the health
    if(health<0) {
        //Clear the interrupts
        cli();
    }
    else {
        //Display new health
        LCDdisplay(damage, health);
    }//end if
}//end coolDownMode()
示例#7
0
/**
  * Creating needed connections
  */
void MainWindow::createConnections()
{
    connect(ui->leSearch, SIGNAL(returnPressed()), this, SLOT(searchAudio()));

    connect(playerControls, SIGNAL(play()), player, SLOT(play()));
    connect(playerControls, SIGNAL(pause()), player, SLOT(pause()));
    connect(playerControls, SIGNAL(volumeChanged(int)), player, SLOT(setVolume(int)));
    connect(playerControls, SIGNAL(playPositionChanged(qint64)), player, SLOT(setPosition(qint64)));

    connect(player, SIGNAL(positionChanged(qint64)), playerControls, SLOT(setPlayPosition(qint64)));
    connect(player, SIGNAL(durationChanged(qint64)), playerControls, SLOT(setAudioLength(qint64)));
    connect(player, SIGNAL(volumeChanged(int)), playerControls, SLOT(setVolume(int)));
    connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), playerControls, SLOT(setState(QMediaPlayer::State)));
    connect(playlist, SIGNAL(titleChange(QString)), playerControls, SLOT(setTitle(QString)));

    connect(playerControls, SIGNAL(previous()), playlist, SLOT(previous()));
    connect(playerControls, SIGNAL(next()), playlist, SLOT(next()));

    connect(playerControls, SIGNAL(configure()), this, SLOT(showSettingsDialog()));

    connect(vkaudio, SIGNAL(statusChanged(QString, int)), this->statusBar(), SLOT(showMessage(QString,int)));

    connect(ui->tvSongs, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(playAudio()));
    connect(ui->tvSongs, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showSongsContextMenu(QPoint)));
    connect(ui->tvPlaylists, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showPlaylistsContextMenu(QPoint)));
}
示例#8
0
文件: main.c 项目: island-org/island
void setup()
{
    setupPAudio();
    speech = loadSpeech(sentence);
    playAudio(speech);

    font = loadFont("../3rdparty/nanovg/example/Roboto-Regular.ttf");
}
示例#9
0
void TargetFileComponent::actionListenerCallback(const juce::String &message){

    if(message == "audioPositionUpdateWhilePlaying"){
        playAudio();
    }
    else{
        sendActionMessage(message);
    }
//    DBG(message);
}
示例#10
0
void *threadPayAudio (void *parameters){
	unsigned char audiobuf[1024*64];
	config *audioParamters = (config*) parameters;
	fd=configAudio(*audioParamters,O_WRONLY);
	int size;
	while(1){
		size=read(ipc[0], audiobuf, sizeof(audiobuf));
		playAudio(fd,audiobuf,size);
	}
}
示例#11
0
文件: menu.c 项目: lin826/Slapjack
void Loser()
{
    loseTimes++;
    int count=1;
    Image *loser;
    int ran,i;
    srand( time(NULL) );
    ran=rand()%2;
    while(count<=6)
    {

        clearScreen();
        switch(count)
        {

        case 1:
            loser= read_image("Loser1.pixel","Loser1.color");
            break;
        case 2:
            loser= read_image("Loser2.pixel","Loser2.color");
            break;
        case 3:
            loser= read_image("Loser3.pixel","Loser3.color");
            break;
        case 4:
            loser= read_image("Loser4.pixel","Loser4.color");
            break;
        case 5:
            loser= read_image("Loser5.pixel","Loser5.color");
            break;
        case 6:
            loser= read_image("Loser6.pixel","Loser6.color");
        default:
            break;


        }
        count++;
        show_image(loser,120,35);
        drawCmdWindow();  /* update window immediately */


        for(i=0; i<1; i++)
        {
            playAudio(&audioLose[ran]);
            //Sleep(100);
        }

        Sleep(300);
    }
    destroy_image(loser);
    showTable();
}
示例#12
0
文件: menu.c 项目: lin826/Slapjack
void Loser2(int x,int y)  //small lose send location
{
    int count=1;
    Image *loser;
    int ran,i;
    srand( time(NULL) );
    ran=rand()%2;
    while(count<=6)
    {

        clearScreen();
        switch(count)
        {

        case 1:
            loser= read_image("Loser21.pixel","Loser21.color");
            break;
        case 2:
            loser= read_image("Loser22.pixel","Loser22.color");
            break;
        case 3:
            loser= read_image("Loser23.pixel","Loser23.color");
            break;
        case 4:
            loser= read_image("Loser24.pixel","Loser24.color");
            break;
        case 5:
            loser= read_image("Loser25.pixel","Loser25.color");
            break;
        case 6:
            loser= read_image("Loser26.pixel","Loser26.color");
        default:
            break;


        }
        count++;
        show_image(loser,x,y);
        drawCmdWindow();  /* update window immediately */


        for(i=0; i<1; i++)
        {
            playAudio(&audioLose[ran]);
            //Sleep(300);
        }

        Sleep(300);
    }
    destroy_image(loser);

}
示例#13
0
void Agent::tickVoices() {
	for (int i = 0; i < (int)pending_voices.size(); i++) {
		std::pair<std::string, unsigned int> &entry = pending_voices[i];
		if (entry.second == 0) {
			// uncontrolled audio is easier, we shall hope no-one notices
			playAudio(entry.first, false, false);
			pending_voices.erase(pending_voices.begin() + i);
			i--;
		} else {
			entry.second--;
		}
	}
}
示例#14
0
文件: menu.c 项目: lin826/Slapjack
void playAudioNUM(int index)
{

    int ran,i;
    srand( time(NULL) );
    ran=rand()%2;
    for(i=0; i<1; i++)
    {
        playAudio(&audioNUM[index][ran]);
        Sleep(0);
    }


}
示例#15
0
void new_vi(void)
{
    int Dif;
    unsigned int CurrentFPSTime;
    static unsigned int LastFPSTime = 0;
    static unsigned int CounterTime = 0;
    static unsigned int CalculatedTime ;
    static int VI_Counter = 0;

    playAudio();

    double AdjustedLimit = VILimitMilliseconds * 100.0 / l_SpeedFactor;  // adjust for selected emulator speed
    int time;

    start_section(IDLE_SECTION);
    VI_Counter++;

#ifdef DBG
    if(g_DebuggerActive) DebuggerCallback(DEBUG_UI_VI, 0);
#endif

    if(LastFPSTime == 0)
    {
        LastFPSTime = CounterTime = ticksGetTicks();
        return;
    }
    CurrentFPSTime = ticksGetTicks();
    
    Dif = CurrentFPSTime - LastFPSTime;
    
    if (Dif < AdjustedLimit) 
    {
        CalculatedTime = (unsigned int) (CounterTime + AdjustedLimit * VI_Counter);
        time = (int)(CalculatedTime - CurrentFPSTime);
        if (time > 0)
        {
            usleep(time * 1000);
        }
        CurrentFPSTime = CurrentFPSTime + time;
    }

    if (CurrentFPSTime - CounterTime >= 1000.0 ) 
    {
        CounterTime = ticksGetTicks();
        VI_Counter = 0 ;
    }
    
    LastFPSTime = CurrentFPSTime ;
    end_section(IDLE_SECTION);
}
示例#16
0
OPAL_SOUND_MGR bool SoundManager::setSound( unsigned int audioID, Vector3 position,
										   Vector3 velocity, Vector3 direction, float maxDistance,
										   bool playNow, bool forceRestart, float minGain )
{
	if ( audioID >= MAX_AUDIO_SOURCES || !mAudioSourceInUse[ audioID ] )
		return false;

	// Set the position
	ALfloat pos[] = { position.x, position.y, position.z };

	alSourcefv( mAudioSources[ audioID ], AL_POSITION, pos );

	if ( checkALError( "setSound::alSourcefv:AL_POSITION" ) )
		return false;

	// Set the veclocity
	ALfloat vel[] = { velocity.x, velocity.y, velocity.z };

	alSourcefv( mAudioSources[ audioID ], AL_VELOCITY, vel );

	if ( checkALError( "setSound::alSourcefv:AL_VELOCITY" ) )
		return false;

	// Set the direction
	ALfloat dir[] = { velocity.x, velocity.y, velocity.z };

	alSourcefv( mAudioSources[ audioID ], AL_DIRECTION, dir );

	if ( checkALError( "setSound::alSourcefv:AL_DIRECTION" ) )
		return false;

	// Set the max audible distance
	alSourcef( mAudioSources[ audioID ], AL_MAX_DISTANCE, maxDistance );

	// Set the MIN_GAIN ( IMPORTANT - if not set, nothing audible! )
	alSourcef( mAudioSources[ audioID ], AL_MIN_GAIN, minGain );

	// Set the max gain
	alSourcef( mAudioSources[ audioID ], AL_MAX_GAIN, 1.0f ); // TODO as parameter ? global ?

	// Set the rollof factor
	alSourcef( mAudioSources[ audioID ], AL_ROLLOFF_FACTOR, 1.0f ); // TODO as parameter ?

	// Do we play the sound now ?
	if ( playNow ) return playAudio( audioID, forceRestart ); // TODO bof... not in this fct

	return true;
}
示例#17
0
void ControlBar::playButtonClicked()
{
   if (isAudioPlaying)
   {
       this -> playButton -> setIcon( this -> style() -> standardIcon(QStyle::SP_MediaPlay));
       emit pauseAudio();
   }
   else
   {
       this -> playButton -> setIcon( this -> style() -> standardIcon(QStyle::SP_MediaPause));
       emit playAudio();
   }

   isAudioPlaying = !isAudioPlaying;

}
示例#18
0
//Update for GameLoop
void LevelTwo::update(float dt)
{
	playAudio();

	if (addPlatfroms == true)
	{
		createHiddenPlatforms();
		addPlatfroms = false;
	}

	if (player->getPhysicsBody()->getVelocity().y == 0 || playersColliding == true)
	{
		p1Jumped = false;
		//playersColliding = false;
	}
	else
		p1Jumped = true;

	if (player2->getPhysicsBody()->getVelocity().y == 0 || playersColliding == true)
	{
		p2Jumped = false;
	}
	else
		p2Jumped = true;

	if (playerOneDead == true)
	{
		player->respawnPoint(player, 2);
		playerOneDead = false;
	}

	if (playerTwoDead == true)
	{
		player2->respawnPoint(player2, 2);
		playerTwoDead = false;
	}

	if (playerOneEndGame == true && playerTwoEndGame == true)
	{
		showEndGame();
	}

	this->scheduleOnce(schedule_selector(LevelTwo::createFlames), 2.7f);
	//createFlames(checkCollision);
	//cameraTarget->setPosition(player->getPositionX(), player->getPositionY());
}
/*=============================
void mainLoop

inputs: none
returns: n/a

Creates a loop while health > 0 that first
checks to see if mana is above zero,
then if it is not it calls coolDownMode(),
otherwise it polls the bowNocked method
to check for user input. If bowNocked is
TRUE, get the drawStrength in a local uint8_t
by calling drawStrength(), and calls sendIR() using
the drawStrength variable.

Written by: Katie Hobble
=================================*/
void mainLoop() {
    //Create an infinite loop to run while the bow is in use
    while(health > 0) {
        //First, check to see if mana is less than 0. If it is, enter
        //cool down mode to replenish mana
        if(mana <= 0) {
            //Mana needs to be replenished, enter cool down mode.
            coolDownMode();
        }//end if

        //We get here only if mana is at an acceptable amount.
        //Poll the bowNocked method to see if there has been any user input
        if(bowNocked()) {

            //Play the bow nocked sound
            playAudio(soundInput, 0);
            //User input was detected by bowNocked() method. Call the
            //drawStrength() method to get the draw strength of the user's
            //shot in the form of a uint8_t
            int drawStrength = measureDrawStrength();

            //Pass the uint8_t drawStrength to the sendIR method if its greater than 0
            if(drawStrength > 0) {
                //Display the bow's firing power
                LCDdisplay(fire,drawStrength);
                //Send the damage packets
                sendIR(drawStrength);
            }//end if
        }//end if
    }//end while

    //Health is less than zero, send out some stun packets through PC3 (short range)
    for(int i = 0; i < 5; i++) {
        //Send the start envelope
        FiveSixK(10, 0x08);
        //Send the first stun data envelpe
        FiveSixK(40, 0x08);
        //Repeat the stun data envelope
        FiveSixK(40, 0x08);
        //Send stop envelope
        FiveSixK(150, 0x08);
        //Delay a little bit
        _delay_ms(50);
    }//end for
}//end mainLoop
示例#20
0
void TargetFileComponent::buttonClicked (Button* buttonThatWasClicked)
{
    //[UserbuttonClicked_Pre]
    //[/UserbuttonClicked_Pre]

    if (buttonThatWasClicked == playButton)
    {
        //[UserButtonCode_playButton] -- add your button handler code here..
        playAudio();
        //[/UserButtonCode_playButton]
    }
    else if (buttonThatWasClicked == stopButton)
    {
        //[UserButtonCode_stopButton] -- add your button handler code here..
        stopAudio();
        //[/UserButtonCode_stopButton]
    }
    else if (buttonThatWasClicked == loadFileButton)
    {
        //[UserButtonCode_loadFileButton] -- add your button handler code here..
        FileChooser myChooser ("Please select the file you want to load...");
        if (myChooser.browseForFileToOpen())
        {
            audioTransport.setSource(nullptr); // this fixes memory issue with loading new file

            File selectedFile = myChooser.getResult();
            currentFile->setFile(selectedFile);

            container->setFile(selectedFile);

            audioTransport.setSource(currentFile->getSource());

            isPlayable = true;
            setPlayable(true);
            sendActionMessage("setTargetFile");

        }
        //[/UserButtonCode_loadFileButton]
    }

    //[UserbuttonClicked_Post]
    //[/UserbuttonClicked_Post]
}
/*=============================
void sendIR

inputs: int drawStrength
returns: n/a

Fires a damage packet for every increment
of drawStrength. Also decreases mana based
on the drawStrength.

Written by: Katie Hobble
=================================*/
void sendIR(int drawStrength) {
    //Decrease mana if the strength is greater than 0
    if (drawStrength > 0) {
        //Decrease mana according to its value (it'll be either 0 or mana-drawStrength)
        if(mana - drawStrength < 0) {
            //Set mana to be zero if it was going to be negative
            mana = 0;
            manaCount = 0;
        }
        else {
            //Set mana to be itself minus the drawstrength
            mana = mana - drawStrength;
            manaCount = 0;
        }//end if

        //Play the firing sound
        playAudio(shoot, drawStrength);
        //Delay for a little to let it play
        _delay_ms(300);
        //Turn off sound
        PORTD = 0xFF;

        //Send Damage Packet to PC4 (long range)
        for (int i = 0; i < drawStrength; i ++) {
            //Send start envelope
            FiveSixK(10, 0x10);
            //Send damage data envelope
            FiveSixK(20, 0x10);
            //Send damage repeat data evelope
            FiveSixK(20, 0x10);
            //Send stop envelope
            FiveSixK(150, 0x10);
            //Delay for a little
            _delay_ms(50);
        }//end for

        //Display the new mana
        LCDdisplay(plasma, mana);
    }//end if
}//end sendIR
示例#22
0
文件: menu.c 项目: lin826/Slapjack
void Winner2(int x,int y)
{
    int count=1;
    Image *winner;
    int ran,i;
    srand( time(NULL) );
    ran=rand()%2;
    int time=7;
    while(time--)
    {
        clearScreen();
        switch(count)
        {
        case 1:
            winner= read_image("Winner21.pixel","Winner21.color");
            break;
        case 2:
            winner= read_image("Winner22.pixel","Winner22.color");
            break;
        case 3:
            winner= read_image("Winner23.pixel","Winner23.color");
            break;
        default:
            break;
        }

        count=(count+1)%4;
        show_image(winner,x,y);
        drawCmdWindow();  /* update window immediately */

        for(i=0; i<1; i++)
        {
            playAudio(&audioWin[ran]);
            //Sleep(300);
        }

        Sleep(200);
    }
    destroy_image(winner);
}
示例#23
0
void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
	int pause = 0;
	int quit = 0;
	int bbp = buffered_before_play;
	int doCrossFade = 0;
	int crossFadeChunks = 0;
	int fadePosition;
	int nextChunk = -1;
	int test;
        int decodeWaitedOn = 0;
	char silence[CHUNK_SIZE] = { 0 };
	int previousMetadataChunk = -1;
	MetadataChunk currentMetadataChunk;
	int currentChunkSent = 1;
	int end;
	int next = -1;

//		fprintf(stderr,"In decode.c decodeParent func :\r\n");
	if(waitOnDecode(pc,dc,cb,&decodeWaitedOn)<0) return;

        pc->elapsedTime = 0;
	pc->state = PLAYER_STATE_PLAY;
	pc->play = 0;
	kill(getppid(),SIGUSR1);

	while(mpm_get_id(MPM_DECODE)>0 && cb->end-cb->begin<bbp && 
				cb->end!=buffered_chunks-1 &&
				dc->state!=DECODE_STATE_STOP) 
	{
		processDecodeInput();
		if(quit) return;
		playSilenceOrSleep();
	}

	while(!quit) {
		processDecodeInput();
                handleDecodeStart();
		handleMetadata(cb, pc, &previousMetadataChunk, 
				&currentChunkSent, &currentMetadataChunk);
		if(dc->state==DECODE_STATE_STOP && 
			pc->queueState==PLAYER_QUEUE_FULL &&
			pc->queueLockState==PLAYER_QUEUE_UNLOCKED) 
		{
			next = cb->end;
			dc->start = 1;
			pc->queueState = PLAYER_QUEUE_DECODE;
			kill(getppid(),SIGUSR1);
		}
		if(next>=0 && doCrossFade==0 && !dc->start && 
				dc->state!=DECODE_STATE_START) 
		{
			nextChunk = -1;
			if(isCurrentAudioFormat(&(cb->audioFormat))) {
				doCrossFade = 1;
				crossFadeChunks = 
				calculateCrossFadeChunks(pc,
                                        &(cb->audioFormat));
				if(!crossFadeChunks ||
						pc->crossFade>=dc->totalTime) 
				{
					doCrossFade = -1;
				}
			}
			else doCrossFade = -1;
		}

		/* copy thse to locale variables to prevent any potential
			race conditions and weirdness */
		end = cb->end;

		if(pause) my_usleep(10000);
		else if(cb->begin!=end && cb->begin!=next) {
			if(doCrossFade==1 && next>=0 &&
					((next>cb->begin && 
					(fadePosition=next-cb->begin)
					<=crossFadeChunks) || 
					(cb->begin>next &&
					(fadePosition=next-cb->begin+
					buffered_chunks)<=crossFadeChunks)))
			{
				if(nextChunk<0) {
					crossFadeChunks = fadePosition;
				}
				test = end;
				if(end < cb->begin) test+=buffered_chunks;
				nextChunk = cb->begin+crossFadeChunks;
				if(nextChunk<test) {
					if(nextChunk>=buffered_chunks)
					{
						nextChunk -=  buffered_chunks;  
					}
					pcm_mix(cb->chunks+cb->begin*CHUNK_SIZE,
							cb->chunks+nextChunk*
							CHUNK_SIZE,
							cb->chunkSize[
								cb->begin],
							cb->chunkSize[
								nextChunk],
							&(cb->audioFormat),
							((float)fadePosition)/
							crossFadeChunks);
					if(cb->chunkSize[nextChunk]>
							cb->chunkSize[cb->begin]
							)
					{
						cb->chunkSize[cb->begin]
								= cb->chunkSize
								[nextChunk];
					}
				}
				else {
					if(dc->state==DECODE_STATE_STOP)
					{
						doCrossFade = -1;
					}
					else continue;
				}
			}
			pc->elapsedTime = cb->times[cb->begin];
			pc->bitRate = cb->bitRate[cb->begin];
			pcm_volumeChange(cb->chunks+cb->begin*
				CHUNK_SIZE,
				cb->chunkSize[cb->begin],
				&(cb->audioFormat),
				pc->softwareVolume);
			if(playAudio(cb->chunks+cb->begin*CHUNK_SIZE,
				cb->chunkSize[cb->begin])<0) 
			{
				quit = 1;
			}
			if( cb->begin+1 >= buffered_chunks ) {
				cb->begin = 0;
			}
			else cb->begin++;
		}
		else if(next==cb->begin) {
			if(doCrossFade==1 && nextChunk>=0) {
				nextChunk = cb->begin+crossFadeChunks;
				test = cb->end;
				if(end < cb->begin) test+=buffered_chunks;
				if(nextChunk<test) {
					if(nextChunk>=buffered_chunks)
					{
						nextChunk -= buffered_chunks;
					}
					advanceOutputBufferTo(cb, pc, 
						&previousMetadataChunk,
						&currentChunkSent, 
						&currentMetadataChunk, 
						nextChunk);
				}	
			}
			while(pc->queueState==PLAYER_QUEUE_DECODE ||
					pc->queueLockState==PLAYER_QUEUE_LOCKED)
			{
				processDecodeInput();
				if(quit) {
					quitDecode(pc,dc);
					return;
				}
		fprintf(stderr,"In decode.c decodeParent while loop with my_usleep\r\n");
//				my_usleep(10000);
			}
			if(pc->queueState!=PLAYER_QUEUE_PLAY) {
				quit = 1;
				break;
			}
			else {
				next = -1;
				if(waitOnDecode(pc,dc,cb,&decodeWaitedOn)<0) {
                                        return;
                                }
				nextChunk = -1;
				doCrossFade = 0;
				crossFadeChunks = 0;
				pc->queueState = PLAYER_QUEUE_EMPTY;
				kill(getppid(),SIGUSR1);
			}
		}
		else if(mpm_get_id(MPM_DECODE)<=0 || 
				(dc->state==DECODE_STATE_STOP && !dc->start)) 
		{
			quit = 1;
			break;
		}
		else {
			if(playAudio(silence, CHUNK_SIZE) < 0) quit = 1;
		}
	}

	quitDecode(pc,dc);
}
示例#24
0
void TabMainWidget::on_listSlices_doubleClicked(const QModelIndex &index)
{
    playAudio();
}
示例#25
0
int single_game(){
    Audio RRR;
    openAudioFile(".\\wav\\RRR.wav", &RRR);
	initializeKeyInput();
	Character yg = characterMaking1(".\\pic\\yg.pixel",".\\pic\\yg.color");
	int key_val[NUM_KEYS]={VK_A,VK_D,VK_ESCAPE};
	int stand=0,score=0,standBrick,pDown1,pDown2;
	double drop=0,scoreCount=0;
	Brick bricks[15];
	int i,j,k;
    char scoreStr[4]={'0'};
	for(i=0;i<10;i++){
		bricks[i].y=-1;
		bricks[i].w=40;
		bricks[i].h=2;
		if(i%2==0)bricks[i].color=15;
		else if(i<=5)bricks[i].color=8;
		else if(i>5)bricks[i].color=12;
		else bricks[i].color=10;
	}
	bricks[0].x=0;
	bricks[0].y=100;
	Font *large_font=read_font("font.txt");
	float lastbrick=0;
	int hp = 10,second=0;
	float rate=0.15;
	while(1){
		clearScreen();
		srand(clock());
        for(i=0;i<10;i++){
            if(bricks[i].y>0)bricks[i].y--;
            else if(bricks[i].y==0)bricks[i].y=-100;
            for(k=0;k<2;k++){
                for(j=0;j<bricks[k].w;j++){
                    putString(bricks[i].x+j,bricks[i].y+k,"=",bricks[i].color,0);
                }
            }
        }
        if(score>50){
            rate = 0.2;
        }
        else if(score>75){
            rate = 0.25;
        }
        else if(score>100){
            rate = 0.3;
        }
		if((float)clock()/(float)CLOCKS_PER_SEC-(float)lastbrick>rate&&rand()%10==1){
			for(i=0;i<10;i++){
				if(bricks[i].y<0){
					bricks[i].y=170;
					bricks[i].x=rand()%185;
					lastbrick=(float)clock()/(float)CLOCKS_PER_SEC;
					for(k=0;k<2;k++){
                        for(j=0;j<bricks[i].w;j++){
                            putString(bricks[i].x+j,bricks[i].y+k,"=",bricks[i].color,0);
                        }
                    }
					break;
				}
			}
		}

        for(k=0;k<10;k++){
        	if(abs(yg.y+yg.h-bricks[k].y)<=2&&(
            (yg.x+yg.w>bricks[k].x&&yg.x+yg.w<bricks[k].x+bricks[k].w)||
            (yg.x>bricks[k].x&&yg.x<bricks[k].x+bricks[k].w))){
        		stand=1;
        		standBrick=k;
        		yg.y=bricks[k].y-yg.h;
                break;
			}
			else if(k==9){
                stand=0;
                standBrick=-1;
			}
		}

        if(stand==1){
            drop=0;
            second++;
            if(bricks[standBrick].color==15&&second==15){
                second=0;
                if(hp<10)hp++;
            }
            else if(bricks[standBrick].color==12){
                second++;
                if(second==20){
                    second=0;
                    hp--;
                    playAudio(&RRR);
                }
            }
            else if(bricks[standBrick].color==8){
                if(second==10){
                    second=0;
                    bricks[standBrick].y=-100;
                }
            }
		}
		else{
            if(drop<2)drop+=0.5;
            yg.y+=(int)drop;
            second=0;
		}

		if(yg.y<0){
            yg.y+=10;
            drop=3;
            hp-=4;
            playAudio(&RRR);
		}
		for (k = 0 ; k < NUM_KEYS ; k++){
            if(KEY_DOWN(key_val[k])){
                switch (key_val[k]){
	                case VK_A:
	                	if(yg.x>=0)yg.x-=5;
	                	break;
	                case VK_D:
	                	if(yg.x+yg.w<225)yg.x+=5;
	                	break;
                    case VK_ESCAPE:
                        return 3;
                        break;
          	  	}
            }
        }
        show_image(yg.pic,yg.x,yg.y);
        for(i=0;i<225;i++){
            for(j=151;j<=170;j++){
                putString(i,j," ",0,0);
            }
        }
		putStringLarge(large_font,159,158,"HP ",15);
		putStringLarge(large_font,159,152,"STAGE ",15);
		scoreCount++;
		score = (pow(scoreCount/300,1.5));
		scoreStr[0]=score/100+'0';
		scoreStr[1]=score/10%10+'0';
		scoreStr[2]=score%10+'0';
		putStringLarge(large_font,201,152,scoreStr,15);
		for(i=0;i<hp;i++){
            for(j=1;j<5;j++){
                for(k=0;k<=4;k++)putString(180+i*4+j,158+k,"|",12,0);
            }
		}
		for(i=0;i<225;i++)putString(i,0,"V",12,0);
        for(i=0;i<225;i++){
            putString(i,149,"=",12,0);
        }
        for(i=0;i<150;i++){
            putString(0,i,"|",0,12);
            putString(224,i,"|",0,12);
        }
        drawCmdWindow();
        if(yg.y>150||hp<=0){
            break;
		};
        if(KEY_UP(VK_P)&&pDown1)pDown1=0;
        if(KEY_UP(VK_P)&&pDown2)pDown2=0;
        if(KEY_DOWN(VK_P)&&!pDown1){
            pDown1=1;
            putStringLarge(large_font,45,70,"Press P to continue",12);
            drawCmdWindow();
            Sleep(500);
            while(1){
                if(KEY_DOWN(VK_P)&&!pDown2){
                    pDown2=1;
                    break;
                }
            }
        }
		Sleep(20);
	}
	pauseAudio(&RRR);
	Image * jh =read_image(".\\pic\\jh.pixel",".\\pic\\jh.color");
	show_image(jh,15,30);
    putStringLarge(large_font,75,80,"SCORE ",15);
    putStringLarge(large_font,120,80,scoreStr,15);
    drawCmdWindow();
	Audio *barbar;
	openAudioFile(".\\wav\\88wav.wav",&barbar);
	playAudio(&barbar);
	Sleep(3500);
	int flagg = 1;
    putStringLarge(large_font, 45, 90, "Press esc to exit", 15);
    drawCmdWindow();
    while(flagg){
        if(KEY_DOWN(VK_ESCAPE))return 3;
    }
	clearScreen();
}
示例#26
0
void TabMainWidget::on_btnPlay_clicked()
{
    if (ui->listSlices->selectedItems().count() > 0)
        playAudio();
}
示例#27
0
void AudionManager::playStartGameAudio()
{
    const char* audio_startgame = getAudioConfig()["StartGame"].GetString();
    playAudio(audio_startgame);
}
示例#28
0
文件: gamecontrol.c 项目: jur/Ballion
static void mp3_decoderThread(SceSize args, void *param)
{
	while(1) {
		playAudio();
	}
}
示例#29
0
void AudionManager::playShootAudio()
{
    const char* audio_shoot = getAudioConfig()["Shoot"].GetString();
    playAudio(audio_shoot);
}
示例#30
0
void AudionManager::playExplosionAudio()
{
    const char* audio_hit = getAudioConfig()["Hit"].GetString();
    playAudio(audio_hit);
}