Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411283 Posts in 69325 Topics- by 58380 Members - Latest Member: bob1029

March 29, 2024, 08:01:25 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperAudioA Question about looping.
Pages: [1]
Print
Author Topic: A Question about looping.  (Read 2247 times)
Nessiah
Level 1
*


Today is a gift that's why it's called the present


View Profile WWW
« on: August 09, 2009, 08:42:22 PM »

I'm trying to use construct (might be applicable to other progs) but how do you guys make music loop where it repeats a particular segment of the song rather than repeating the whole song?

if I explained it wrong then...
Whole song plays
loops not from the beginning.
« Last Edit: August 09, 2009, 09:12:07 PM by Nessiah » Logged

Loren Schmidt
Level 10
*****



View Profile WWW
« Reply #1 on: August 10, 2009, 12:15:24 AM »

I haven't used Construct, but in Flash I did something similar. Music tracks had an intro at the beginning, followed by a section that loops seamlessly.

I made an external file which contains track names and looping information for each file. Then I read that in. The tracks were then played from the beginning the first time, with an event listener attached to the track. The event listener triggered when the sound ended, and then it started again, but from the loop point.

I don't know how much help this is (given that I don't know Construct at all) but good luck!
Logged
Craig Stern
Level 10
*****


I'm not actually all that stern.


View Profile WWW
« Reply #2 on: August 10, 2009, 03:45:48 AM »

Hey Sparky, would you mind sharing some of the Actionscript code you used to do that? I've been curious about how to make that work as well, but in Flash. Smiley
Logged

pgil
Guest
« Reply #3 on: August 10, 2009, 06:44:55 AM »

I just cut songs into an intro part and a looping part. Play the intro part, then have a script running each frame to check when it's done playing. Then play the looping part.
Logged
Craig Stern
Level 10
*****


I'm not actually all that stern.


View Profile WWW
« Reply #4 on: August 10, 2009, 04:28:43 PM »

Sure. But what's the code that checks to see if the sound is done playing?
Logged

george
Level 7
**



View Profile
« Reply #5 on: August 10, 2009, 04:55:45 PM »

I'm curious about this too, as even though I haven't used Construct yet I've been meaning to try it out. Looking at the XAudio2 object it seems like music and sound effects are treated separately, even though it seems like you could play music through a sound effect channel if the music was in .ogg format. You can check if a sound effect is playing, but I don't see how you can tell explicitly if the music stream is playing...it seems like the conditions and properties of XAudio are available only for channels (for which you could check if a file is playing, etc.), not the music stream, or am I not understanding that correctly?
Logged
Loren Schmidt
Level 10
*****



View Profile WWW
« Reply #6 on: August 10, 2009, 05:32:57 PM »

Hey Sparky, would you mind sharing some of the Actionscript code you used to do that? I've been curious about how to make that work as well, but in Flash. Smiley
Sure; I'm happy to share anything I write, but I should warn that it is quite likely to be horribly backward. I'm really not much of a programmer. If I recall correctly I had some trouble loading files from the paths in the xml file, and had to hard code it.

http://pastebin.org/8069

And here's sample content of the music.xml file:
http://pastebin.org/8074
Logged
Craig Stern
Level 10
*****


I'm not actually all that stern.


View Profile WWW
« Reply #7 on: August 11, 2009, 04:26:14 AM »

Cool, thanks!
Logged

rogerlevy
Guest
« Reply #8 on: August 11, 2009, 03:58:13 PM »

Sparky, allow me to give you a small XML tip.  Use attributes instead of nested nodes for data.  Then you can access an attribute of an XML object simply by saying:

xml.@attribute
 Beer!
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic