Old 05-22-2009, 10:45 PM   #1 (permalink)
Zuner
 
badmoodguy88's Avatar
 
Join Date: Jun 2008
Posts: 72
badmoodguy88 is on a distinguished road
Default generate music loops from soundclips

This is very basic code to take some sound clips and play them in a repeating sequence. The reason for doing this is to play background music for a game using less memory. In my case each SoundEffect is a 16beat measure and the tempo is VERY high.

This is not for a sequencer program but it that is sort of what this code does.
It really is not that hard. Plus I kind of find it annoying when a game calls the play song method because it stops my music.

Code:
        SoundEffect  Void0, Void1, Void2, Void3, Voidsynth0, Voidsynth1, Voidsynth2;
        SoundEffectInstance V0, V1;
Code:
                    if (playcounter < 24)
                    {
                        playcounter++;
                    }
                    else
                    {
                        if (beat == 0) { V0 = Void0.Play(Volume); V1 = Voidsynth0.Play(Volume); }
                        if (beat == 1) { V0 = Void0.Play(Volume); }
                        if (beat == 2) { V0 = Void0.Play(Volume); }
                        if (beat == 3) { V0 = Void0.Play(Volume); }

                        if (beat == 4) { V0 = Void1.Play(Volume); V1 = Voidsynth1.Play(Volume); }
                        if (beat == 5) { V0 = Void1.Play(Volume); }
                        if (beat == 6) { V0 = Void1.Play(Volume); }
                        if (beat == 7) { V0 = Void1.Play(Volume); }

                        if (beat == 8) { V0 = Void2.Play(Volume); V1 = Voidsynth0.Play(Volume); }
                        if (beat == 9) { V0 = Void3.Play(Volume); }
                        if (beat == 10) { V0 = Void3.Play(Volume); }
                        if (beat == 11) { V0 = Void3.Play(Volume); }

                        if (beat == 12) { V0 = Void0.Play(Volume); V1 = Voidsynth2.Play(Volume); }
                        if (beat == 13) { V0 = Void0.Play(Volume); }
                        if (beat == 14) { V0 = Void0.Play(Volume); }
                        if (beat == 15) { V0 = Void0.Play(Volume); beat = -1; }
                        beat++;
                        playcounter = 0;
                    }



badmoodguy88 is offline   Reply With Quote

Advertisement [Remove Advertisement]
Old 05-22-2009, 10:52 PM   #2 (permalink)
lost in paradise with rae
Support Team
Moderator
Expert Zuner
 
Red Sky's Avatar
 
Join Date: Nov 2007
Location: Pennsylvania
Posts: 2,662
Red Sky is just really niceRed Sky is just really niceRed Sky is just really nice
Send a message via MSN to Red Sky
Default

I noticed you don't reset beat anywhere, and when sound 15 plays, beat goes down one. does this mean that sounds 14 and 15 will be the only sounds to repeat? That what appears to happen, anyway.





Red Sky is offline   Reply With Quote
Old 05-23-2009, 01:53 AM   #3 (permalink)
Zuner
 
badmoodguy88's Avatar
 
Join Date: Jun 2008
Posts: 72
badmoodguy88 is on a distinguished road
Default

It is on the same line as if (beat == 15) which is the last beat.
I set it to beat = -1; because it is still bumped up by one ( beat++; ) so that by the end it is set to 0.



badmoodguy88 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools