Game Development Community

Enable networked music composition

by JesseL · in Torque 3D Professional · 07/02/2009 (5:24 am) · 6 replies

As a side discussion: Caution this is heavly edited as I figure stuff out.
I've always thought that having a simple music composition applet would be a neat feature in a game. One that you compose music in a gui and play it for everyone and even play notes off the keyboard and people in your group could listen to if they wanted. That being said. How would one go about doing this?
Things that I figure need to be done:
Get pictures of all of the notes / staffs etc. -- Done

Create a GUI interface that I can arrange the notes / staffs on -- No Idea here. Help Please?
Also allow the GUI to save the song that was arrange and load a song file.
I was thinking that the format
www.lilypond.org
lilypond.org/doc/v2.12/Documentation/user/lilypond/index
uses would be fine.

If it is compatible with lilypond's software they can publish the recordings as PDF sheet music by just running the file through the program. That might make people like using it.

Take a int(byte 8 bits): 128 being middle C. 129 C# 127 B.
Every 12 notes is a different octave. That gives me about 10 different octaves. I would think that plenty.

Network the song int along with network traffic using concepts from the following resources:
tdn.garagegames.com/wiki/Torque/Networking/Server_and_Client

tdn.garagegames.com/wiki/TorqueNetworking

opentnl.sourceforge.net/doxytree/introprogramming.html

It should be really easy to implement but I don't know how to yet :/ Help Please :)

The client would submit its information to the server the server would then forward it to the group members.

On the clients computers there would be a .wav file that is the instrument played at middle C.
They would take the int values and create pitch alternative based on what value was sent and play the .wav file with the pitch change. I'm not sure on what formula to use to calculate the pitch :/ Help Please :)
I found the formula for Torque now to look at the Engine Code and see if I can figure out how to use pitch.
www.phy.mtu.edu/~suits/NoteFreqCalcs.html

About the author

I just realized that if I wanted to create a cat that caught on fire and ran up a telephone pole and then burst into a blue waterfall. That wouldn't be to hard!


#1
07/02/2009 (7:02 am)
The pitch changing is the same principle behind MIDI and other sequenced music: you have samples for each instrument and when a note is being played you play that sample with a modified pitch. So, reading resources about sequenced music is a good idea. You'll find pitch values for different tones.

Getting it networked in Torque would be pretty simple, but you'd need to do some extra work to make sure the network latency doesn't mess up the timing of the notes. Off the top of my head I think it could be done by storing notes to be played in a buffer that holds 1 or 2 seconds or music in the clients, and have they play the oldest notes (so the clients are always 1 or 2 seconds behind the server). This would allow you to have some sort of timestamp sent alongside the notes to allow them to be played with the correct time intervals between them, and avoid risking variable latency to mess up the music.
#2
07/02/2009 (8:36 am)
I would actually try to get some kind of highly accurate, synchronized quantization going on, then you can just start throwing notes at the clients with some info on how they go together, and (save for network failures) you should be golden.

As far as the pitch question, there are pitch controls on the audio handles in Torque. I think Wav is not what you are looking for, though.
#3
07/02/2009 (9:07 am)
its easy to make music that sounds correct if I just change the pitch of the note from Middle C. or the A below middle C or the A above middle C.

Holy Cow. How do you expose setPitch and getPitch to console. I just rambeled through:
sfxEmitter.h .cpp
which takes me to
sfxProfile.h .cpp; sfxSystem.h .cpp
which takes me to
sfxSource.h .cpp which is where I assumed I wanted to get the setPitch and getPitch from.
#4
07/06/2009 (12:57 am)
Any help would be appreciated? Anyone have any Ideas? Thank you in advance!
#5
07/15/2009 (1:07 am)
Looks like they decided to add pitch to the SFX description and SFX emitter.

www.garagegames.com/community/forums/viewthread/96093
#6
08/03/2009 (4:09 am)
Ok figured out how to use the Drag and Drop Gui method to drag resources from a list to a Image that can be put on a staff line.