diff projects/tank_wars/main.cpp @ 268:8d80eda512cd prerelease

Added new overlay for using PRU0 or PRU1, a script to halt board on button press, and several example projects
author andrewm
date Tue, 17 May 2016 14:46:26 +0100
parents 3c3a1357657d
children
line wrap: on
line diff
--- a/projects/tank_wars/main.cpp	Tue May 17 14:38:03 2016 +0100
+++ b/projects/tank_wars/main.cpp	Tue May 17 14:46:26 2016 +0100
@@ -19,6 +19,9 @@
 int gMusicBufferLength = 0;
 float *gSoundBoomBuffer = 0;
 int gSoundBoomBufferLength = 0;
+float *gSoundHitBuffer = 0;
+int gSoundHitBufferLength = 0;
+
 
 using namespace std;
 
@@ -80,7 +83,8 @@
 	BeagleRTInitSettings settings;	// Standard audio settings
 	string musicFileName = "music.wav";
 	string soundBoomFileName = "boom.wav";
-
+	string soundHitFileName = "hit.wav";
+	
 	struct option customOptions[] =
 	{
 		{"help", 0, NULL, 'h'},
@@ -121,7 +125,10 @@
 	if(loadSoundFile(soundBoomFileName, &gSoundBoomBuffer, &gSoundBoomBufferLength) != 0) {
 		cout << "Warning: unable to load sound file " << soundBoomFileName << endl;
 	}
-
+	if(loadSoundFile(soundHitFileName, &gSoundHitBuffer, &gSoundHitBufferLength) != 0) {
+		cout << "Warning: unable to load sound file " << soundHitFileName << endl;
+	}
+	
 	// Initialise the PRU audio device
 	if(BeagleRT_initAudio(&settings, 0) != 0) {
 		cout << "Error: unable to initialise audio" << endl;
@@ -154,7 +161,9 @@
 		free(gMusicBuffer);
 	if(gSoundBoomBuffer != 0)
 		free(gSoundBoomBuffer);
-
+	if(gSoundHitBuffer != 0)
+		free(gSoundHitBuffer);
+	
 	// All done!
 	return 0;
 }