当前位置: 首页>>代码示例>>C++>>正文


C++ Audio类代码示例

本文整理汇总了C++中Audio的典型用法代码示例。如果您正苦于以下问题:C++ Audio类的具体用法?C++ Audio怎么用?C++ Audio使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Audio类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

quint32 FunctionManager::createFunction(int type, QStringList fileList)
{
    Function* f = NULL;
    QString name;

    switch(type)
    {
        case Function::SceneType:
        {
            f = new Scene(m_doc);
            name = tr("New Scene");
            m_sceneCount++;
            emit sceneCountChanged();
        }
        break;
        case Function::ChaserType:
        {
            f = new Chaser(m_doc);
            name = tr("New Chaser");
            if (f != NULL)
            {
                /* give the Chaser a meaningful common duration, to avoid
                 * that awful effect of playing steps with 0 duration */
                Chaser *chaser = qobject_cast<Chaser*>(f);
                chaser->setDuration(1000);
            }
            m_chaserCount++;
            emit chaserCountChanged();
        }
        break;
        case Function::SequenceType:
        {
            /* a Sequence depends on a Scene, so let's create
             * a new hidden Scene first */
            Function *scene = new Scene(m_doc);
            scene->setVisible(false);

            if (m_doc->addFunction(scene) == true)
            {
                f = new Sequence(m_doc);
                name = tr("New Sequence");
                Sequence *sequence = qobject_cast<Sequence *>(f);
                sequence->setBoundSceneID(scene->id());
                m_sequenceCount++;
                emit sequenceCountChanged();
            }
            else
                delete scene;
        }
        break;
        case Function::EFXType:
        {
            f = new EFX(m_doc);
            name = tr("New EFX");
            m_efxCount++;
            emit efxCountChanged();
        }
        break;
        case Function::CollectionType:
        {
            f = new Collection(m_doc);
            name = tr("New Collection");
            if (m_selectedIDList.count())
            {
                Collection *collection = qobject_cast<Collection *>(f);
                for (QVariant fID : m_selectedIDList)
                    collection->addFunction(fID.toUInt());
            }

            m_collectionCount++;
            emit collectionCountChanged();
        }
        break;
        case Function::RGBMatrixType:
        {
            f = new RGBMatrix(m_doc);
            name = tr("New RGB Matrix");
            m_rgbMatrixCount++;
            emit rgbMatrixCountChanged();
        }
        break;
        case Function::ScriptType:
        {
            f = new Script(m_doc);
            name = tr("New Script");
            m_scriptCount++;
            emit scriptCountChanged();
        }
        break;
        case Function::ShowType:
        {
            f = new Show(m_doc);
            name = tr("New Show");
            m_showCount++;
            emit showCountChanged();
        }
        break;
        case Function::AudioType:
        {
            name = tr("New Audio");
//.........这里部分代码省略.........
开发者ID:ming-hai,项目名称:qlcplus,代码行数:101,代码来源:functionmanager.cpp

示例2: TEST_CASE

TEST_CASE("Test Mono Operator Overloads", ""){
    
    int sampleRate = 44100,
        bitCount = 16,
        channels = 1;
        
    std::vector<int16_t> samplesA = {-1, 1, 2, -2, 3, -3, 10, -10};
    Audio<int16_t> a(sampleRate, bitCount, channels, samplesA);
    
    SECTION("Test concatenate operator a|b"){
        //GIVEN: some audio objects a and b
        std::vector<int16_t> samplesB = {-1, 1, 2, -2, 3, -3, 10, -10};
        Audio<int16_t> b(sampleRate, bitCount, channels, samplesB);
        
        //WHEN: we concatenate them using the concatenation operator
        Audio<int16_t> concatenated = a | b;
        
        //THEN: the result should be the two files back to back
        std::vector<int16_t> expected = {-1, 1, 2, -2, 3, -3, 10, -10, -1, 1, 2, -2, 3, -3, 10, -10};
        REQUIRE( concatenated.getData().size() == expected.size() );
        REQUIRE( concatenated.getData() == expected );
    }
    
    SECTION("Test volume factor operator a*f"){
        //GIVEN: some audio object a        
        //WHEN: we apply the volume factor operator with 0.5
        Audio<int16_t> factored = a * std::pair<float, float>(0.5f, 0.5f);
        
        //THEN: the result should have all samples halved and clamped
        std::vector<int16_t> expected = {0, 0, 1, -1, 1, -1, 5, -5};
        REQUIRE( factored.getData().size() == expected.size() );
开发者ID:muhummadPatel,项目名称:cs3022a5,代码行数:31,代码来源:test.cpp

示例3: main

int main(int argc, char *argv[])
{
    char *option;

    if ((argc != 3) || (*argv[1] != '-')) {
        usage();
        exit(1);
    }
    else {
        option = argv[1] + 1;
        if (*option == 'h') {
            usage();
            exit(1);
        }
        
        // Create an input bitstream
        Bitstream bs(argv[2], BS_INPUT);

        // Automatic detection
        if (*option == '-') {

            // Create our Audio object
            Audio audio;
        
            // Parse
            while (!bs.atend()) {
#ifdef USE_EXCEPTION
                try {
                    audio.get(bs); 
                    switch (audio.type) {
                    case 3: {   // WAV format
                        // For the data chunk, read one data element at a time
                        if (audio.wav->ckData->available) {
                            WAVData wd;
                            for (int i = 0; i < audio.wav->ckData->ckSize; i=i+audio.wav->ckFormat->bitsPerSample/8) 
                                wd.get(bs, audio.wav->ckFormat->bitsPerSample);
                            audio.wav->ckData->available = 0;
                        }
                        break;
                    }
                    case 2: {   // AIFF/AIFC format
                        // For the sound data chunk, read one data element at a time
                        if (audio.aiff->ckSound->available) {
                            SoundData sd;
                            for (int i = 0; i < audio.aiff->ckSound->ckSize; i++) 
                                sd.get(bs);
                            audio.aiff->ckSound->available = 0;
                        }
                        break;
                    }
                    case 1: {   // NeXT/Sun audio format
                        // Read one data element at a time
                        AUData aud;
                        for (int i = 0; i < audio.auh->dataSize; i++)
                            aud.get(bs);
                        break;
                    }
                    default:    // 8-bit raw format
                        break;
                    }
                }
                catch (Bitstream::EndOfData e) {
		            fprintf(stdout, "End of file\n");
		            exit(1);
	            }
                catch (Bitstream::Error e) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], e.getmsg());
                    exit(1);
                }
#else 
                audio.get(bs);
                switch (audio.type) {
                case 3: {   // WAV format
                    if (audio.wav->ckData->available) {
                        WAVData wd;
                        for (int i = 0; i < audio.wav->ckData->ckSize; i=i+audio.wav->ckFormat->bitsPerSample/8) 
                            wd.get(bs, audio.wav->ckFormat->bitsPerSample);
                        audio.wav->ckData->available = 0;
                    }
                    break;
                }
                case 2: {   // AIFF/AIFC format
                    if (audio.aiff->ckSound->available) {
                        SoundData sd;
                        for (int i = 0; i < audio.aiff->ckSound->ckSize; i++) 
                            sd.get(bs);
                        audio.aiff->ckSound->available = 0;
                    }
                    break;
                }
                case 1: {   // NeXT/Sun audio format
                    AUData aud;
                    for (int i = 0; i < audio.auh->dataSize; i++)
                        aud.get(bs);
                    break;
                }
                default:    // 8-bit raw format
                    break;
                }
                if (bs.geterror() == E_END_OF_DATA) {
//.........这里部分代码省略.........
开发者ID:RushOnline,项目名称:bouquet,代码行数:101,代码来源:main.cpp

示例4: TEST_CASE

#include "Audio.h"
#include <stdlib.h>
#define CATCH_CONFIG_MAIN  
#include "catch.hpp"

using namespace MSHIMA001;
using namespace std;


TEST_CASE( "testing mono audio files ", "8 bit" ) {
   
      
      vector<int8_t> v1{3, 78, 23, -67, 12, 4};
      Audio<int8_t , 1> a1(1, 8, 2, v1);
      
        
      vector<int8_t> v2{5, 60, 43, -70, 34, 12};
      Audio<int8_t , 1> a2(1, 8, 2, v2);
      
      
            
      //additon
      //expected sum 
        vector<int8_t> v3{8, 127, 66, -127, 46, 16};

      Audio<int8_t , 1> a3(1, 8, 2, v3);

      Audio<int8_t, 1>  sum  = a1 + a2;
      REQUIRE(sum == a3);

      
开发者ID:imaculate,项目名称:SAMP,代码行数:29,代码来源:Tests.cpp

示例5: f

void MediaDialog::addAudioPressed()
      {
      QString path = audioFile->text();
      if (score->audio() || path.isEmpty())
            return;
      QFile f(path);
      if (!f.open(QIODevice::ReadOnly))
            return;
      QByteArray ba = f.readAll();
      f.close();
      Audio* audio = new Audio;
      audio->setPath(path);
      audio->setData(ba);
      score->setAudio(audio);
      score->setDirty(true);
      mscore->updatePlayMode();

#if 0
      QString wavPath = QDir::tempPath() + "/score.wav";
      mscore->saveAs(score, true, wavPath, "wav");
      QString program = "D:/HACK/sonic-annotator/bologna.bat";
      QStringList arguments;
      arguments << QDir::toNativeSeparators(path)<< QDir::toNativeSeparators(wavPath);
      QProcess myProcess(this);
      myProcess.start(program, arguments);
      myProcess.waitForFinished();
      qDebug() << myProcess.readAll();
#endif

      QFileInfo fi(path);
      QFile syncFile(fi.absolutePath() + "/" + fi.baseName() + ".txt");

      TempoMap* tmo = score->tempomap();

      if (!syncFile.open(QIODevice::ReadOnly))
            return;

      qreal t = 0;
      int tick = 0;
      qreal lastTempo = tmo->tempo(0);
      TempoMap* tmn = new TempoMap();
      tmn->setTempo(0, lastTempo);
      int resolution = 25;
      while (!syncFile.atEnd()) {
            for (int i = 0; !syncFile.atEnd() && i < resolution-1; i++)
                  syncFile.readLine();

            if (syncFile.atEnd())
                  break;

            QByteArray line = syncFile.readLine();
            QString s(line);
            QStringList sl = s.split(":");

            qreal tScore = sl[0].trimmed().toDouble();
            qreal tPerformance = sl[1].trimmed().toDouble();

            // timestamp of last
            int scoreTick = tmo->time2tick(tScore);
            qreal deltaError = tmo->tick2time(scoreTick) - tScore;
            int dt = scoreTick - tick;
            qreal deltaTime = tPerformance - t;

            if (deltaTime > 0) {
                  qreal tempo = dt / (480 * deltaTime);
                  if(tempo != lastTempo) {
                  qDebug() << tempo;
                        tmn->setTempo(tick, tempo);
                        lastTempo = tempo;
                        }
                  }

            t = tPerformance - deltaError;
            tick = scoreTick;
            }
      score->setTempomap(tmn);
      syncFile.close();
      QMessageBox::information(0, "Done", "Done");
      }
开发者ID:33akash,项目名称:MuseScore,代码行数:79,代码来源:mediadialog.cpp

示例6: ex_pitch_chain

bool ex_pitch_chain(void *args) {

	ITheFramework *frame = Factory::GetFramework ();

	Decorator *decorator = ssi_create (Decorator, 0, true);
	frame->AddDecorator(decorator);

	// audio sensor	
#ifndef SIMULATE
	Audio *audio = ssi_create (Audio, "audio", true);
	audio->getOptions()->scale = true;		
	ITransformable *audio_p = frame->AddProvider(audio, SSI_AUDIO_PROVIDER_NAME);
#else
	WavReader *audio = ssi_create (WavReader, 0, true);
	audio->getOptions()->setPath("audio.wav");
	audio->getOptions()->scale = true;		
	audio->getOptions()->block = 0.01;
	ITransformable *audio_p = frame->AddProvider(audio, SSI_WAVREADER_PROVIDER_NAME);
#endif	
	frame->AddSensor(audio);

	// pitch
	OSPitchChain *pitch = ssi_create (OSPitchChain, "pitch", true);	
	pitch->getOSTransformFFT()->getOptions()->nfft = 1024;
	pitch->getOSPitchShs()->getOptions()->baseSr = audio_p->getSampleRate();
	ITransformable *pitch_t = frame->AddTransformer(audio_p, pitch, "0.01s", "0.01s");

	// plot
	SignalPainter *plot = 0;	

	plot = ssi_create_id (SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("audio");
	plot->getOptions()->type = PaintSignalType::AUDIO;
	plot->getOptions()->size = 10.0;		
	frame->AddConsumer(audio_p, plot, "0.01s");
	
	plot = ssi_create_id (SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("pitch");
	plot->getOptions()->size = 10.0;
	frame->AddConsumer(pitch_t, plot, "0.01s"); 

	FileWriter *writer = ssi_create (FileWriter, 0, true);
	writer->getOptions()->setPath("pitch_chain");
	writer->getOptions()->type = File::ASCII;
	frame->AddConsumer(pitch_t, writer, "0.01s");

#ifdef SIMULATE
	AudioPlayer *player = ssi_create(AudioPlayer, "player", true);
	frame->AddConsumer(audio_p, player, "0.01s");
#endif

	// run framework
	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	frame->Start();
	frame->Wait();
	frame->Stop();
	frame->Clear();	

	return true;
}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:63,代码来源:opensmile_testMain.cpp

示例7: ex_vad

bool ex_vad(void *args) {

	//general
	ITheFramework *frame = Factory::GetFramework ();

	Decorator *decorator = ssi_create (Decorator, 0, true);
	frame->AddDecorator(decorator);

	ITheEventBoard *board = Factory::GetEventBoard ();
	ssi_pcast (TheEventBoard, board)->getOptions()->update = 250;

	// audio sensor	
#ifndef SIMULATE
	Audio *audio = ssi_create (Audio, "audio", true);
	audio->getOptions()->scale = true;		
	ITransformable *audio_p = frame->AddProvider(audio, SSI_AUDIO_PROVIDER_NAME);
#else
	WavReader *audio = ssi_create (WavReader, 0, true);
	audio->getOptions()->setPath("audio.wav");
	audio->getOptions()->scale = true;		
	ITransformable *audio_p = frame->AddProvider(audio, SSI_WAVREADER_PROVIDER_NAME);
#endif	
	frame->AddSensor(audio);

	SignalPainter *audio_plot = ssi_create_id (SignalPainter, 0, "plot");
	audio_plot->getOptions()->setTitle("audio");
	audio_plot->getOptions()->size = 10.0;		
	audio_plot->getOptions()->type = PaintSignalType::AUDIO;
	frame->AddConsumer(audio_p, audio_plot, "0.2s");

	OSLpc * lpc = ssi_create (OSLpc, 0, true);
	lpc->getOptions()->lsp = true;
	ssi::ITransformable *lpc_p = frame->AddTransformer(audio_p, lpc, "160");
	
	OSPitchChain * pitch = ssi_create (OSPitchChain, 0, true);
	pitch->getOSPitchShs()->getOptions()->voicingC1 = true;
	pitch->getOSPitchSmoother()->getOptions()->voicingC1 = true;
	ssi::ITransformable *pitch_p = frame->AddTransformer(audio_p, pitch, "160", "160");
	
	OSEnergy * energy = ssi_create (OSEnergy, 0, true);
	energy->getOptions()->type = OSEnergy::TYPE::LOG;
	ssi::ITransformable *energy_p = frame->AddTransformer(audio_p, energy, "160");

	OSVad * vad = ssi_create (OSVad, 0, true);
	ssi::ITransformable * src[3] = {lpc_p, pitch_p, energy_p};
	frame->AddConsumer(3, src, vad, "0.01s");
	board->RegisterSender(*vad);

	EventMonitor *monitor = ssi_create_id (EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, vad->getEventAddress());

#ifdef SIMULATE
	AudioPlayer *player = ssi_create (AudioPlayer, "player", true);
	frame->AddConsumer(audio_p, player, "0.01s");
#endif

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:70,代码来源:opensmile_testMain.cpp

示例8:

//===========================================
// MusicTrack::~MusicTrack
//===========================================
MusicTrack::~MusicTrack() {
   Audio audio;
   audio.freeMusicTrack(this);
}
开发者ID:yuang1516,项目名称:dodge,代码行数:7,代码来源:MusicTrack.cpp

示例9: Asset

//===========================================
// MusicTrack::MusicTrack
//===========================================
MusicTrack::MusicTrack(const string& file)
   : Asset(internString("MusicTrack")) {

   Audio audio;
   audio.newMusicTrack(this, file);
}
开发者ID:yuang1516,项目名称:dodge,代码行数:9,代码来源:MusicTrack.cpp

示例10: check_mouse

void check_mouse(XEvent *e, Game *game)
{
    static int savex = 0;
    static int savey = 0;
    static int n = 0;
    Audio *a;
    a = &game->sounds;


    if (e->type == ButtonRelease) {
            return;
    }
    if (e->type == ButtonPress && lvlState(game) < 0) {
        //LEFT-CLICK
        if (e->xbutton.button==1) {
            //Left button was pressed
            int y = WINDOW_HEIGHT - e->xbutton.y;
            //Check game state when LEFT-clicking
            if (gameState(game) == 1 || gameState(game) == 2) {
                a->playAudio(30);
                menuClick(game);
                a->playAudio(32);
            } else if (gameState(game) == 0) {
                // JBC Added 5/30 to only make defense 
                // missiles and play sound when enemy 
                // missiles are present
                if ((game->nmissiles > 0 ||
               game->nsmissiles > 0) &&
            game->defMissilesRemaining > 0) {
                        makeDefenseMissile(game, e->xbutton.x, y);
                        a->playAudio(20);
                        game->defMissilesRemainingAfterLevel = 
                            game->defMissilesRemaining;
                }
            }
            return;
        }
        //RIGHT-CLICK
        if (e->xbutton.button==3) {
            //Check game state when RIGHT-clicking
            if (gameState(game) == 1) {
                //Menu functions
            } else if (gameState(game) == 0) {
                //Game Functions
                // fireDefenseMissile(game);
                // JBC idea to add menu pop up for right-click
                game->gState ^= 1;
            }
            return;
        }
    }
    //Did the mouse move?
    if (savex != e->xbutton.x || savey != e->xbutton.y) {
            savex = e->xbutton.x;
            savey = e->xbutton.y;
            int y = WINDOW_HEIGHT - e->xbutton.y;
            if (++n < 10)
                    return;
            if (gameState(game) == 1 || gameState(game) == 2) {
                //Menu Functions
                mouseOver(savex, y, game);
            } else if (gameState(game) == 0) {
                //Game Functions
                if (game->lcm)
                    lastCityMode(savex, y, game);
                // JBC note 5/13
                // moved the "particle" stuff out of here 
                // makeParticle(game, e->xbutton.x, y);
            }
    }
}
开发者ID:MissileCommand,项目名称:MissileCommand,代码行数:71,代码来源:missileCommand.cpp

示例11: Display


//.........这里部分代码省略.........
		//6		
		D3DXMatrixTranslation(&tripler, RavengerSirenPos.x, RavengerSirenPos.y, RavengerSirenPos.z);
		D3DXMatrixScaling(&grow, .1/sizeModifier, .1/sizeModifier, .1/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		RavengerSiren.Draw(Stone);
		//7		
		D3DXMatrixTranslation(&tripler, SectoidPos.x, SectoidPos.y, SectoidPos.z);
		D3DXMatrixScaling(&grow, 3/sizeModifier, 3/sizeModifier, 3/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Sectoid.Draw(Stone);
		//8		
		D3DXMatrixTranslation(&tripler, SlendermanPos.x, SlendermanPos.y, SlendermanPos.z);
		D3DXMatrixScaling(&grow, .05/sizeModifier, .05/sizeModifier, .05/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Slenderman.Draw(Stone);
		//9		
		D3DXMatrixTranslation(&tripler, SoccerPos.x, SoccerPos.y, SoccerPos.z);
		D3DXMatrixScaling(&grow, .05/sizeModifier, .05/sizeModifier, .05/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Soccer.Draw(Stone);
		//10		
		D3DXMatrixTranslation(&tripler, TurretPos.x, TurretPos.y, TurretPos.z);
		D3DXMatrixScaling(&grow, .1/sizeModifier, .1/sizeModifier, .1/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Turret.Draw(Stone);
		//11		
		D3DXMatrixTranslation(&tripler, UltramanPos.x, UltramanPos.y, UltramanPos.z);
		D3DXMatrixScaling(&grow, .01/sizeModifier, .01/sizeModifier, .01/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Ultraman.Draw(Stone);
		//12		
		D3DXMatrixTranslation(&tripler, ZombiePos.x, ZombiePos.y, ZombiePos.z);
		D3DXMatrixScaling(&grow, .1/sizeModifier, .1/sizeModifier, .1/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Zombie.Draw(Stone);

		if(!shrunk && p.z > 10)
		{
			shrunk = true;
			sound.AudioPlay(Voice);
			::MessageBoxA(0, "OH NO! you appear to be Shrinking\nStart Running to try and reach the manor", "Oh No!", MB_OK);
			DTime *= 5;
		}
		else if(shrunk)
		{
			
			if(sizeModifier >1)
			{
				sizeModifier-=.005;
			}
			else if(message)
			{
				message = false;
				::MessageBoxA(0, "It's too late, however you seem to be at the entrance to a castle and there appears to be some createures on the inside.\nMaybe you should try to approach one of them, Be Careful Though: they could be Evil", "Too Late", MB_OK);
			}
		}
		static bool approach = false;
		if(!approach)
			if(p.z > 125)
			{
				::MessageBoxA(0, "The creatures seem to be frozen and have had all their color drained...\nThey look like they were once the things that only exis in nightmares\nWhat kind of Powerfull Monster could have done this?\nMaybe you shouldn't have ignored those warnings.", "", MB_OK);
				approach = true;
			}
			static bool bang = false;
		if(p.z > 0)
		{
			if(!bang)
			{
				bang = true;
				sound.AudioPlay(Bang);
			}
			Device->SetStreamSource(0, VBufferGround, 0, sizeof(Vertex));
			Device->SetFVF(FVF_VERTEX);
			Device->SetTexture(0, DoNot);
			Device->SetTransform(D3DTS_WORLD, &i);
			Device->DrawPrimitive(D3DPT_TRIANGLELIST, 36, 2);
			Device->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
		}

		
		D3DXMATRIX V, T;
		TheCamera.getViewMatrix(&V);
		Device->SetTransform(D3DTS_VIEW, &V);
		TheCamera.getPosition(&p);
		if (p.y != 8.5)
			p.y = 8.5;
		TheCamera.setPosition(&p);
		TheCamera.getLook(&t);
		Device->EndScene();
		Device->Present(0, 0, 0, 0);
	}
	return true;
}
开发者ID:Odinra,项目名称:DirectX,代码行数:101,代码来源:Main.cpp

示例12: playjumpsound

	// Base class
	void PlayerState::playjumpsound() const
	{
		using Audio::Sound;
		Sound(Sound::JUMP).play();
	}
开发者ID:am910021,项目名称:JourneyClient,代码行数:6,代码来源:PlayerStates.cpp

示例13: D3DXCOLOR

void ColoredCubeApp::initApp()
{

    D3DApp::initApp();
    //input->initialize(getMainWnd(), false);
    //audio->initialize();

    float boxScale = 0.5f;
    float collisionFixFactor = 1.1f;
    currentBullet = 0;
    explosionTimer = 0;
    explosionRunning = false;
    shotRelease = true;

    // increments when you run into a cube // just for now
    score = 0;
    mAxes.init(md3dDevice, 1.0f);
    mEnemy.init(md3dDevice, .5f, RED);
    mPlayer.init(md3dDevice, .5f, BLUE);
    mBullet.init(md3dDevice, .25f, D3DXCOLOR(0.0f, 1.0f, 0.0f, 0.0f));
    particleBox.init(md3dDevice, .01f, GREEN);
    particleBox2.init(md3dDevice, .04f, RED);
    starBox.init(md3dDevice, 0.05f, WHITE);
    //mBox.init(md3dDevice, boxScale);
    mLine.init(md3dDevice, 1.0f);
    //mTriangle.init(md3dDevice, 1.0f);
    //mQuad.init(md3dDevice, 10.0f);
    mQuad.init(md3dDevice, 0.0f);

    gameObject1.init(&mPlayer, sqrt(2.0f), Vector3(6,.5,0), Vector3(0,0,0), 5.0f,1.0f);
    //gameObject1.init(&mBox, sqrt(2.0f), Vector3(6,.5,0), Vector3(0,0,0), 5000.0f,1.0f);
    gameObject1.setRadius(gameObject1.getRadius()*boxScale*collisionFixFactor);

    int step = 2;
    for (int i = 0; i < MAX_NUM_ENEMIES; i++)
    {
        enemyObjects[i].init(&mEnemy, sqrt(2.0), Vector3(-5,.5,step*i - 3.8), Vector3(1,0,0), 8.0f, 1);
        //enemyObjects[i].init(&mBox, sqrt(2.0), Vector3(-5,.5,step*i - 3.8), Vector3(1,0,0), 3000.0f, 1);
        enemyObjects[i].setRadius(enemyObjects[i].getRadius()*boxScale * collisionFixFactor);
        enemyObjects[i].setInActive();
    }

    for (int i = 0; i < MAX_NUM_BULLETS; i++)
    {
        playerBullets[i].init(&mBullet, 0.5f, Vector3(0,0,0), Vector3(-12,0,0), 0.0f, 1);
        playerBullets[i].setInActive();
    }

    for (int i = 0; i < MAX_NUM_EXP_PARTICLES; i++)
    {

        if(i%5 == 0)particles[i].init(&particleBox2, 0.5f, Vector3(0,0,0), Vector3(0,0,0), 7000.0f, 1);
        else particles[i].init(&particleBox, 0.5f, Vector3(0,0,0), Vector3(0,0,0), 7000.0f, 1);
        particles[i].setInActive();
    }

    for (int i = 0; i < MAX_NUM_STARS; i++)
    {
        stars[i].init(&starBox, 0.5f, Vector3(0,0,0), Vector3(0,0,0), 7000.0f, 1);
        stars[i].setActive();
    }

    buildFX();
    buildVertexLayouts();

    audio = new Audio();

    if (*WAVE_BANK != '\0' && *SOUND_BANK != '\0')  // if sound files defined
    {
        if (!audio->initialize()) {

        }

        /*if( FAILED( hr = audio->initialize() ) )
        {
        if( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ) )
        throw(GameError(gameErrorNS::FATAL_ERROR, "Failed to initialize sound system because media file not found."));
        else
        throw(GameError(gameErrorNS::FATAL_ERROR, "Failed to initialize sound system."));
        }*/
    }

    enemyBuffer.resetClock();
    shotBuffer.resetClock();
    gameTimer.resetClock();


    D3DXVECTOR3 pos(10.0f, 2.0f, 0.0f);
    D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
    D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);

    //Camera Object
    camera.init(pos, Vector3(0,0,0), Vector3(0,0,0));
    camera.setPerspective();
    // camera
    cameraPos = pos;

    audio->playCue(BKG);

    //Places stars in scene
//.........这里部分代码省略.........
开发者ID:SamGill,项目名称:Games2-Proj1,代码行数:101,代码来源:Colored+Cube+App.cpp

示例14: renderCollisionOverlay

void ApplicationOverlay::renderAudioMeter() {

    Application* application = Application::getInstance();

    QGLWidget* glWidget = application->getGLWidget();
    Audio* audio = application->getAudio();

    //  Display a single screen-size quad to create an alpha blended 'collision' flash
    if (audio->getCollisionFlashesScreen()) {
        float collisionSoundMagnitude = audio->getCollisionSoundMagnitude();
        const float VISIBLE_COLLISION_SOUND_MAGNITUDE = 0.5f;
        if (collisionSoundMagnitude > VISIBLE_COLLISION_SOUND_MAGNITUDE) {
            renderCollisionOverlay(glWidget->width(), glWidget->height(), audio->getCollisionSoundMagnitude());
        }
    }

    //  Audio VU Meter and Mute Icon
    const int MUTE_ICON_SIZE = 24;
    const int AUDIO_METER_INSET = 2;
    const int MUTE_ICON_PADDING = 10;
    const int AUDIO_METER_WIDTH = MIRROR_VIEW_WIDTH - MUTE_ICON_SIZE - AUDIO_METER_INSET - MUTE_ICON_PADDING;
    const int AUDIO_METER_SCALE_WIDTH = AUDIO_METER_WIDTH - 2 * AUDIO_METER_INSET;
    const int AUDIO_METER_HEIGHT = 8;
    const int AUDIO_METER_GAP = 5;
    const int AUDIO_METER_X = MIRROR_VIEW_LEFT_PADDING + MUTE_ICON_SIZE + AUDIO_METER_INSET + AUDIO_METER_GAP;

    int audioMeterY;
    if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
        audioMeterY = MIRROR_VIEW_HEIGHT + AUDIO_METER_GAP + MUTE_ICON_PADDING;
    } else {
        audioMeterY = AUDIO_METER_GAP + MUTE_ICON_PADDING;
    }

    const float AUDIO_METER_BLUE[] = { 0.0, 0.0, 1.0 };
    const float AUDIO_METER_GREEN[] = { 0.0, 1.0, 0.0 };
    const float AUDIO_METER_RED[] = { 1.0, 0.0, 0.0 };
    const float AUDIO_GREEN_START = 0.25 * AUDIO_METER_SCALE_WIDTH;
    const float AUDIO_RED_START = 0.80 * AUDIO_METER_SCALE_WIDTH;
    const float CLIPPING_INDICATOR_TIME = 1.0f;
    const float AUDIO_METER_AVERAGING = 0.5;
    const float LOG2 = log(2.f);
    const float METER_LOUDNESS_SCALE = 2.8f / 5.f;
    const float LOG2_LOUDNESS_FLOOR = 11.f;
    float audioLevel = 0.f;
    float loudness = audio->getLastInputLoudness() + 1.f;

    _trailingAudioLoudness = AUDIO_METER_AVERAGING * _trailingAudioLoudness + (1.f - AUDIO_METER_AVERAGING) * loudness;
    float log2loudness = log(_trailingAudioLoudness) / LOG2;

    if (log2loudness <= LOG2_LOUDNESS_FLOOR) {
        audioLevel = (log2loudness / LOG2_LOUDNESS_FLOOR) * METER_LOUDNESS_SCALE * AUDIO_METER_SCALE_WIDTH;
    } else {
        audioLevel = (log2loudness - (LOG2_LOUDNESS_FLOOR - 1.f)) * METER_LOUDNESS_SCALE * AUDIO_METER_SCALE_WIDTH;
    }
    if (audioLevel > AUDIO_METER_SCALE_WIDTH) {
        audioLevel = AUDIO_METER_SCALE_WIDTH;
    }
    bool isClipping = ((audio->getTimeSinceLastClip() > 0.f) && (audio->getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME));

    if ((audio->getTimeSinceLastClip() > 0.f) && (audio->getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) {
        const float MAX_MAGNITUDE = 0.7f;
        float magnitude = MAX_MAGNITUDE * (1 - audio->getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME);
        renderCollisionOverlay(glWidget->width(), glWidget->height(), magnitude, 1.0f);
    }

    audio->renderToolBox(MIRROR_VIEW_LEFT_PADDING + AUDIO_METER_GAP,
                         audioMeterY,
                         Menu::getInstance()->isOptionChecked(MenuOption::Mirror));

    audio->renderScope(glWidget->width(), glWidget->height());

    glBegin(GL_QUADS);
    if (isClipping) {
        glColor3f(1, 0, 0);
    } else {
        glColor3f(0.475f, 0.475f, 0.475f);
    }

    audioMeterY += AUDIO_METER_HEIGHT;

    glColor3f(0, 0, 0);
    //  Draw audio meter background Quad
    glVertex2i(AUDIO_METER_X, audioMeterY);
    glVertex2i(AUDIO_METER_X + AUDIO_METER_WIDTH, audioMeterY);
    glVertex2i(AUDIO_METER_X + AUDIO_METER_WIDTH, audioMeterY + AUDIO_METER_HEIGHT);
    glVertex2i(AUDIO_METER_X, audioMeterY + AUDIO_METER_HEIGHT);

    if (audioLevel > AUDIO_RED_START) {
        if (!isClipping) {
            glColor3fv(AUDIO_METER_RED);
        } else {
            glColor3f(1, 1, 1);
        }
        // Draw Red Quad
        glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + AUDIO_RED_START, audioMeterY + AUDIO_METER_INSET);
        glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + audioLevel, audioMeterY + AUDIO_METER_INSET);
        glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + audioLevel, audioMeterY + AUDIO_METER_HEIGHT - AUDIO_METER_INSET);
        glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + AUDIO_RED_START, audioMeterY + AUDIO_METER_HEIGHT - AUDIO_METER_INSET);
        audioLevel = AUDIO_RED_START;
    }
//.........这里部分代码省略.........
开发者ID:BrianPrz,项目名称:hifi,代码行数:101,代码来源:ApplicationOverlay.cpp

示例15: setVolume

//===========================================
// MusicTrack::setVolume
//===========================================
void MusicTrack::setVolume(float vol) {
   Audio audio;
   audio.setMusicTrackVolume(shared_from_this(), vol);
}
开发者ID:yuang1516,项目名称:dodge,代码行数:7,代码来源:MusicTrack.cpp


注:本文中的Audio类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。