Play music with Reggae - questions
  • MDW
  • Order of the Butterfly
    Order of the Butterfly
    MDW
    Posts: 388 from 2003/7/25
    From: Wroclaw/Poland
    I am adding some technical modifications in my latest useless production (demo "Morphever"). One of these changes is playing music. I have some doubts, questions. Maybe someone could help me...

    I use Reggae to play music.

    The first question is about sound file format.
    Music in the demo is in WAVE format (huge file size). I have already tried to use MP3 but during playing, animation is not perfect fluent. Screen is redrawed 60 frames per second, CPU usage always is below 100% (40-70%). But I see some micro-pauses in animation. Animation is not perfect like with disabled sound. If I use WAVE format, animation is fluent.

    Could I do something else for achieve perfect animation with smaller audio-file? Does someone have any idea?

    I play audio file from memory. Unfortunately loading the huge WAVE file (almost 40MB) in to memory on Efika (128MB) is impossible. So today I added possibility to streaming music from file. Now RAM consumption is less and Efika will be able to run the demo with music in WAVE.
    From my point of view both methods work the same. Playing from disc is not slower, doesn't cause any additional breaks in the screen redrawing. During streaming from disc I have the same effect - with MP3 there are small micro-pauses, with WAVE is perfect.

    And I have one additional question about priorities.

    I experimented with task priorities. I would like to know what do you think about this proposal. :)

    I would like to change priorities to:

    If window/screen is active:
    demo task priority: 4
    audio channel priority: 2

    If window/screen is inactive:
    demo task priority: 0
    audio channel priority: 0

    I know that changing priorities is not recommended and this is not good practise. However if I am watching demo or playing a game (especially on fullscreen) I am focused on this and this is the most important for me. Of course as you can see I don't want to set +127... :)
    I see that with proposed priorites demo works better, sound affects less to the animation. But I am not sure if I should do it.
    What do you think about it, MOS-masters?

    Thanks for all answers,
    MDW
  • »06.11.22 - 21:05
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    KennyR
    Posts: 835 from 2003/3/4
    From: #AmigaZeux, Gu...
    Juggling round robin scheduler priorities is not common practice because it's generally ineffective. Any task that needs the CPU for more than a handful of cycles starves anything of lower priority, so you end up in no better situation than when you started.
  • »06.11.22 - 21:45
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    KennyR
    Posts: 835 from 2003/3/4
    From: #AmigaZeux, Gu...
    And if you want the WAV to be smaller you could try writing it out with a software that supports ADPCM compression.

    Warning in advance though... it *will* sound worse.
  • »06.11.22 - 21:48
    Profile
  • MDW
  • Order of the Butterfly
    Order of the Butterfly
    MDW
    Posts: 388 from 2003/7/25
    From: Wroclaw/Poland
    KennyR:
    Thank you.
    So I will be avoiding task priority manipulations. However this is a bit annoying when decoding of a sound format affects to drawing when CPU usage is 50%. I would like to set at least 1 for task and keep 0 for sound. :)

    [ Edited by MDW 07.11.2022 - 18:28 ]
  • »07.11.22 - 17:27
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    polluks
    Posts: 718 from 2007/10/23
    From: Gelsenkirchen,...
    What about DigiBooster? It's supported by Reggae.
    Pegasos II G4: MorphOS 3.9, Zalman M220W · iMac G5 12,1 17", MorphOS 3.17
    Power Mac G3: OSX 10.3 · PowerBook 5,8: OSX 10.5, MorphOS 3.17
  • »07.11.22 - 17:55
    Profile
  • MDW
  • Order of the Butterfly
    Order of the Butterfly
    MDW
    Posts: 388 from 2003/7/25
    From: Wroclaw/Poland
    Quote:

    polluks wrote:
    What about DigiBooster? It's supported by Reggae.

    I don't know. My music was not created in DigiBooster. It probably depends on a modules, number of channels but I think DigiBooster works very well.

    I decided to keep WAVE format streamed from file. It works well.
  • »07.11.22 - 22:37
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Tcheko
    Posts: 462 from 2003/2/25
    From: France
    Hi,

    You can setup a decoding task that feeds a buffer at maximum pace (using left cpu cycles). Setup another task for playing that just grab samples from that buffer.

    Less demanding part in the demo will allows the buffer to fully fill while more demanding part of the demo will make the buffer deplete.

    The decoding task can be run at -1 pri and it will just grab whatever is left CPU wise without hurting other tasks.

    My SoundBankster2 (unreleased) DJing application is using such buffer scheme. I managed a perfectly smooth subpixel scrolling at VBL framerate without tearing while decoding mp3 with 100% cpu usage.

    This trick requires a custom Reggae class for the buffer which I can provide if needed.







    [ Edited by Tcheko 09.11.2022 - 07:13 ]
    Quelque soit le chemin que tu prendras dans la vie, sache que tu auras des ampoules aux pieds.
    -------
    I need to practice my Kung Fu.
  • »09.11.22 - 06:13
    Profile Visit Website
  • MDW
  • Order of the Butterfly
    Order of the Butterfly
    MDW
    Posts: 388 from 2003/7/25
    From: Wroclaw/Poland
    This is very interesting.

    Quote:

    Tcheko wrote:
    This trick requires a custom Reggae class for the buffer which I can provide if needed.

    Now everything works correctly for me (using WAVE format). However I will probably back to this problem with MP3 and write to you a message for more details.
    Maybe this feature should be implemented in official Reggae class and available from the API...

    Thank you for the info!
  • »10.11.22 - 13:42
    Profile Visit Website