Search Unity

How to control looping AudioSource tracker modules in the .xm, .mod, .it formats

Discussion in 'Editor & General Support' started by vonchor, May 2, 2012.

  1. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    249
    I've been experimenting with "tracker" files (.mod, .it, etc) and there seems to be an issue with looping: specifically, whether previewing in the editor, playing in the editor, or running on a target (I only tried an Ipad, though), the files loop regardless of the "looping" setting. I tried about 1/2 dozen files and they all do the same thing. These files play back just fine in OpenMPT and don't seem to be set up for looping in any way (I don't think that's even an in-the-file option anyway).

    To be specific, I have an audiosource with a .it file set as it's audio clip and PlayOnAwake true, Loop false. Plays forever in "editor play", or when looking at the clip in the inspector (loop is off in inspector) or when playing on an Ipad.

    I'm going to try programming this as a "oneshot" clip and see what happens - will add to this thread later.

    ->later is now and using a simple script to push the oneshot clip to the audiosource has the same result. I even set looping false after starting the clip playing. Endless looping. Sigh...


    So is this a bug, a feature, or something I don't understand? :)

    BTW although I know you can easily have a coroutine that checks IsPlaying in order to see if the playback is complete, it'd be nice to have a delegate for this.

    Final comment: I have to assume this is a bug, and I created a demo project then submitted it to the bug tracker. One hopes this can be fixed!
     
    Last edited: May 4, 2012
  2. starbork

    starbork

    Joined:
    Jun 5, 2012
    Posts:
    2
    I'd love to hear a solution to this issue as well. I have several .xm files that I'm trying to play in a random order, using if (!audio.isPlaying) . This works fine with .mp3 assets, since Unity knows when they "stop". But with imported .xm or .mod files, in the asset preview, I see that the duration for these formats is always "Unlimited" and they loop endlessly.

    Vonchor, if you do find a solution or viable workaround, please let me know? I'm presently mucking about in an .xm editor called MilkyTracker (pretty neat!), but have found no way as yet to signal unity of an "end" to an .xm file.

    Good luck, and thanks in advance for any help.
     
  3. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    249
    well what I ended up doing is: I created a simple jukebox that just polls the audiosource for the time every time update is called. It compares it to an array of lengths of each song; these I got from the openMPT app. At the proper time I fade one song out, poke in a new file, and play that one.

    BUT in the end I have to say I give up. After all that it appears that playing mod, it, etc files on IOS, at least, is unreliable. I found that with music playing (even only one piece, having nothing to with the jukebox thing, just the audiosource playing a file and I tried several different files) that every once in a while the app would freeze, presumably in FMOD somewhere, since a short piece of the song would just repeat endlessly and everything else was frozen. No console output, and can't break in using the debugger.

    So it's not worth it - I don't want my app to do this. I don't even know how to report it aside from creating an app to demo this somehow and I don't have the time. And the app was never hanging this way before I added the mod file playback so heave ho with that.

    Sorry I can't be more help...
     
  4. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    249
    And btw my original issue is reported to Unity dev as a confirmed bug. But I think so few people are using this feature that it's very low priority and may indeed be an FMOD issue and not a Unity issue.
     
  5. starbork

    starbork

    Joined:
    Jun 5, 2012
    Posts:
    2
    Thanks vonchor. I am also toying with a "known track length" manual array, or partner .xml files for each track. Not a great solution. It's too bad this is broken, since tracker files are so small; here's hoping the Unity devs get to it at some point.

    In any case, good luck to you and thanks for replying.
     
  6. Nodus

    Nodus

    Joined:
    Apr 30, 2013
    Posts:
    1
    Hi

    It might be FMOD related problem not Unity3D since Unity uses stripped down version of FMOD as its audio engine.
    I'm having the same problem but in FMOD Designer when creating interactive music cues using XM format.
    I programmed short 4 bar patterns in MilkyTracker to be used as themes within CUE objects in FMOD. They loop regardless loop setting
    and I've been trying to work it out by adding F00 command at the end of XM pattern to indicate stop but it didn't work. D00 command didn't work either, it's to jump to next pattern..I thought it would work but I was wrong. I have posted about it on FMOD forum only today so need some time for someone to reply. Let's hope there is a solution to this..I find it very tempting to use XM format for interactive music in FMOD with Unity for many obvious reasons.
     
  7. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    249
    Actually, the looping problem was fixed in Unity 4, IIRC as a result of my submitting that as a bug. But the fact is that it's still broken: if you have a tracker file playing as background music and switch scenes then every once in a while (randomly) the audio crashes (starts repeating a small piece over and over again) and the scene change hangs. There's no question it's the use of a tracker file. As soon as I switched back to a normal audio file for BG music the problem went away. I even tried stopping playback and waiting a few frames before changing scenes. Nope. Something is broken... (BTW this seems to occur only with iOS and not in the editor - I don't know about Android because I haven't tried it there).