Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Problems with Audio Files

$
0
0
Okay so I was given a project in which I am to make a simple audio game with a given set of audio files.

The basic idea is that I have 10 audio files, and the player will progress through the game given two choices at the end of each audio file. The user will use the up directional key or the down directional key to make their selection, and progress through the game.

it's like a tree. You start with two choices, and branch off from there.

I have an issue with getting through the game. I'm just using minim to play the audio files, and I can get one audio file to play, but I can't get it to go to another audio file. I want to avoid a switch because they're going to be nested and that gets confusing. I'd rather make separate classes and mesh them together.

But keyPressed only triggers once it seems. I can't get it to trigger more than once, so I can't progress through the game.

This is a really simple program, I don't know what I'm overlooking at all.

So far I have :

  1. import ddf.minim.spi.*;
    import ddf.minim.signals.*;
    import ddf.minim.*;
    import ddf.minim.analysis.*;
    import ddf.minim.ugens.*;
    import ddf.minim.effects.*;

    Minim minim;
    AudioPlayer start;
    AudioPlayer DP1A;
    AudioPlayer DP1B;
    AudioPlayer DP2A;
    AudioPlayer DP2B;
    AudioPlayer DP3A;
    AudioPlayer DP3B;
    AudioPlayer DP4A_5B;
    AudioPlayer DP6A;
    AudioPlayer DP6B;

    void setup()
    {
      size(100, 100);
     
      minim = new Minim(this);
     
      //This loads the song
      start = minim.loadFile("_Start_v1.mp3");
      DP1A = minim.loadFile("DP1A.mp3");
      DP1B = minim.loadFile("DP1B.mp3");
      DP2A = minim.loadFile("DP2A.mp3");
      DP2B = minim.loadFile("DP2B.mp3");
      DP3A = minim.loadFile("DP3A.mp3");
      DP3B = minim.loadFile("DP2B.mp3");
      DP4A_5B = minim.loadFile("DP4A_5B.mp3");
      DP6A = minim.loadFile("DP6A.mp3");
      DP6B = minim.loadFile("DP6B.mp3"); 
    }

    void draw()
    {
      background(0);
       if(keyPressed) {
        if(key == ' ') {
          startStory();
        }
      }
    }

    void startStory()
    {
      if(keyPressed) {
        if(key == ' ' || key == '1') {
          playGame();
      }
    }
    }

    void playGame()
    {
      start.play();
     if(keyPressed) {
       if(key == CODED) {
         if(key == UP) {
           playDP1A();
         }
       }
     }
    }

    void playDP1A()
    {
      start.close();
      DP1A.play();
    }

           
    void stop()
    {
      minim.stop();
      super.stop();
    }




Viewing all articles
Browse latest Browse all 1768

Trending Articles