3. Building the project - OrganisedAFID/sound-pirates GitHub Wiki

After getting the hardware, follow these steps:

Setup your pi

Before installing the game the following packages must be downloaded:

sudo apt-get install 
    libx11-dev libxrandr-dev libasound2-dev libgl1-mesa-dev
    libboost-dev libboost-all-dev  librtaudio-dev 
    libudev-dev libsfml-dev libfftw3-dev
    git make cmake build-essential

Setup your soundcard

Step 1: I2S communication setup

To setup the I2S communication execute these commands:

  1. sudo nano /boot/config.txt
  2. Uncomment the line "#dtparam=i2s=on"
  3. Comment the line "dtparam=audio=on"

Step 2: Select your soundcard as I/O device for your pi

To set your soundcard as the input/output device, execute this command: aplay -l. Then check the line which has: "Device [USB PnP Sound Device]"

It will have a number before it like this: "card 0: Device [USB PnP Sound Device]". In this case, the card number for the soundcard is 0 (Remeber this number).

Now, execute this line: sudo nano /etc/asound.conf and write:

pcm.!default  { <br>
 type hw card <number-of-your-soundcard> <br>
}

ctl.!default { <br>
 type hw card <number-of-your-soundcard>  <br>
}

So, if your soundcard was card number 0, you would write:

pcm.!default  { <br>
 type hw card 0 <br>
}

ctl.!default { <br>
 type hw card 0 <br>
}

Step 3: Reboot

Now you can reboot your pi using the command: sudo reboot and your soundcard should be setup!

Step 4: Test

You can test it with the command: speaker-test which should play some white noise through the speaker connected to the soundcard.

If this fails, you can use this alternative method to make your soundcard work. However it will mean you can't use HDMI with your pi, so only do this if the above steps fail.

Alternative soundcard setup (only use this if the above fails)

Step 1: Select your soundcard as I/O device for your pi

Follow the instructions for Step 2 in the normal setup. Or, if you have already done that, skip this step.

Step 2: Blacklist all other input devices to your pi

Execute the following command:

sudo nano /etc/modprobe.d/raspi-blacklist.conf

Write blacklist snd_bcm2835

Step 3: Reboot

Now you can reboot your pi using the command: reboot and your soundcard should be setup!

Step 4: Test

You can test it with the command: speaker-test which should play some white noise through the soundcard.

Now you should be ready to play the game :)

Running the game

With your pi and soundcard setup you're all set to play sound pirates!

Now just execute these commands:

  • Go into a directory in which you want the game to be.

  • Clone the repo by running: git clone https://github.com/OrganisedAFID/sound-pirates.git

  • Then go to our executable by running: cd sound-pirates/Urho3D/release_build/bin

  • Then run the game: ./sound-pirates

image

After Launching the game

Launching the game will create a start screen where you can view instructions of how to play the game and a start game button. As you select Start game you will hear a tone from the C major scale, it is now your job to replicate that same tone. If you are able to recognize the tone and replay the correct note you will get closer to the spaceship infront of you- one step closer to reaching your goal. If you are unable to replicate the note the space ship will fly further away.

The game ends when either you have caught up to the space PIrates and win the game, or you have played the incorrect note too many times and let the space PIrates get away- loosing the game.