Aller au contenu

Photo

Playing music tracks in sequence


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
henesua

henesua
  • Members
  • 3 871 messages
 I was wondering if there is a proven way to play music tracks in sequence. I don't see any way to detect when a track ends or begins.

#2
henesua

henesua
  • Members
  • 3 871 messages
Well, I suppose for the tracks in question I'll just run a delay script... one for each track, and start the next piece at the right time if a PC is present. It should work.

#3
henesua

henesua
  • Members
  • 3 871 messages
 I posted my solution to pastebin.

The idea is that you execute a recursive script on an area in which you want to cycle through musical tracks.
The area should not have any battle music which could disrupt the background music.
The area also should track whether pcs are present. In on enter I increase th PC count, and on exit I decrement the exit count.
Each track ID and length in seconds are set as INTs on the area.
SONG_ID_01  = song index in ambientmusic.2da for Track 1
SONG_LENGTH_01 = length in senconds that Track 1 will play
SONG_ID_02 .... etc....

aa_ex_music is executed in onAreaEnter.

See 
aa_ex_music   for details of how it works.

[Edit: already found a bug and fixed it. When PCs leave... all music stops and track 1 is set as the first music to play]

Modifié par henesua, 13 février 2012 - 11:33 .


#4
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Hmm, Since there is no module level music player and the tracks will always start anew when a new area is gone into anyway. why not just make a sound object and list the tracks on it. Select either the play in order or random option. basicly use the sound object in place of the Areas background music option.

#5
henesua

henesua
  • Members
  • 3 871 messages
You can put background music on a sound object?

I just checked. The only ambient music I was able to select was the battle music.

Modifié par henesua, 13 février 2012 - 11:38 .


#6
henesua

henesua
  • Members
  • 3 871 messages
 Ok... finished bg testing. I pasted the revised code: aa_ex_music

So... some of these DelayCommands are exceptionally long. One of the tracks has an 673 second delay. Is that a problem?

Anyway, it works. I've got the entire sound track to Before The Rain playing in the Arnheim character creation area. (here's the first track on You-tube. You can find the whole movie there too if you dig.)  Awesome film by the way, Macedonian, about the Balkans, was released in 1994. The soundtrack is by Anastasia, and is as far as I can tell there least electronic sounding album. Many of the instruments used are traditional to the area.

Anyway... the music fits Arnheim. So I am glad to get this script working.

#7
henesua

henesua
  • Members
  • 3 871 messages
Although the last version works, I decided to polish this further and am now very happy with the way this works.
aa_ex_music

This is called by both the enter and exit event. That way the exit event can clean up the music (turn it off completely) when the last player exits. You still need to track player count on the area.

I also added a column to ambientmusic which includes the length of the song in seconds. You'd have to do this as well to use these revisions - in addition to the data entry required for each track. But this way you only have to enter the song lengths once whihc will reduce the chance that you'll make mistakes later.

I also created a juke box using zdlg which changes which track list the area will play. I called each track list a "theme" and created 5 for the out of character lounge.

[edit]
I keep editing that music script. The delays weren't always working right, so I removed them.

Modifié par henesua, 15 février 2012 - 02:50 .