I want to make a game based on the Underground Music scene. If it is a rhythm game the music will make it difficult to meet the 12 MB limit but I’ll see what I can do.
I am currently in a hotel in Malaysia for the next 14 days as I wait for my next teaching job to start. I might not have a lot of time to work on this game but I love Blender and the BGE and I want to participate if I can. I’ll try to post a few updates.
Good Luck everyone!
UPDATE: (I’ll post the most recent screenshot here)
I tried to find a decent way to play midi in the game Engine but I can’t find anything that is easy to set up. I’ve decided at this point to simply play short sound clips and control the pitch of each clip using Python.
Update:
OK, works. Needed some help from this Forum to correctly set the directory for loading the sound files… for some reason the api overview of aud doesn’t cover that.
Based on the combination of info from the two forums, here’s a basic example of using aud:
# import the things
import bge
import aud
# manually set the main directory (necessary for aud)
gameLogic = bge.logic
mainDir = gameLogic.expandPath("//")
device = aud.device()
# load sound file (it can be a video file with audio)
sound = aud.Factory(mainDir + "sounds\" + "bass.ogg")
# play the audio, this return a handle to control play/pause
handle = device.play(sound)
At this point I’ve decided to have each note as a small audio clip and limit the songs to very few different notes. I’m using Audacity to edit the pitch of the notes that I generate in sfxr and adjust things a bit as needed.
Thanks for the link. I want to have different instruments so midi might get really complicated. The manager script you mentioned is probably going to be my next big task.
This is all the code I have so far: nothing fancy.
Right now I’ve set up basic music controls via keyboard and I can bang out some simple rhythms. I wanted the player to be able to choose which band member to be so I have an instrument property and a nested list to control that easily.
import bge
import aud
gameLogic = bge.logic
mainDir = gameLogic.expandPath("//")
#sens = cont.sensors['mySensor']
cont = bge.logic.getCurrentController()
own = cont.owner
instrument = own['instrument']
device = aud.device()
# load sound files (it can be a video file with audio)
bass_1 = aud.Factory(mainDir + "sounds\\" + "bass1.ogg")
bass_2 = aud.Factory(mainDir + "sounds\\" + "bass2.ogg")
bass_3 = aud.Factory(mainDir + "sounds\\" + "bass3.ogg")
bass_4 = aud.Factory(mainDir + "sounds\\" + "bass4.ogg")
kick_1 = aud.Factory(mainDir + "sounds\\" + "kick1.ogg")
kick_2 = aud.Factory(mainDir + "sounds\\" + "kick2.ogg")
kick_3 = aud.Factory(mainDir + "sounds\\" + "kick3.ogg")
kick_4 = aud.Factory(mainDir + "sounds\\" + "kick4.ogg")
# append sound factories to list
noteData = [[bass_1, bass_2, bass_3, bass_4],[kick_1, kick_2, kick_3, kick_4]]
key1 = cont.sensors['key_1'] # 'a' key
key2 = cont.sensors['key_2'] # 's' key
key3 = cont.sensors['key_3'] # 'd' key
key4 = cont.sensors['key_4'] # 'f' key
# play music based on key press:
if key1.positive:
handle1 = device.play(noteData[instrument][0])
if key2.positive:
handle2 = device.play(noteData[instrument][1])
if key3.positive:
handle3 = device.play(noteData[instrument][2])
if key4.positive:
handle4 = device.play(noteData[instrument][3])
So I got hit by a wicked cold for the last few days and couldn’t finish… but I had a lot of fun working through the process! I spent most of my time modeling a run-down apartment for the player to live in. The goal was that clicking on different objects will allow you to pass the time, gain inspiration, and write music to preform downstairs.
What works?
SoundPlayer.py (connected to the empty “sound player”) parses a .csv file and converts it into simple music notes, merges them together into a song, and then plays the result. This script uses the aud framework. Maybe this could be a useful example to the right eyes (or ears?).
In the “facemaker” scene you can move the ‘Piercings’ slider back and forth to control how many piercings you want your character to have [must be in material viewing mode] (I wrote the slider code so that it is relatively easy to adapt for use in other projects that need sliders).
In the “Game” scene, you can left-click on the piano or TV to move the camera to that view or right-click to go back to main view… the idea was going to be that you click on the piano and then choose to compose a song or click on the tv and watch tv to gain inspiration.