Playing sfx and music in application for MorphOS
  • MDW
  • Order of the Butterfly
    Order of the Butterfly
    MDW
    Posts: 451 from 2003/7/26
    From: Wroclaw/Poland
    Together with SDL I also removed SDL_Mixer from my code. Now I have to reimplement playing music nad sfx using something else. I don’t want to use external libraries because MorphOS allows to play sound using its internal libraries. Unfortunately, I don't know anything about sound programming. Could something tell me what I should to use?

    In directory Examples/Reggae of MorphOS SDK I found simple examples how to play an audio from disk or memory using Reggae. They are quite clear. However I would like to know if these methods are recommended for my requirements.

    What I need:
    1. Play from memory several short sounds at the same time.
    2. Play music from disk (e.g. in WAVE format).
    3. Play a sound with specified number of loops.
    4. Play a sound from specified progress.
    5. Check progress of playing music.
    6. Stop specified sound.

    Is Reggae good solution for games/demos or I should use e.g. AHI or OpenAL API?

    Sorry for very basic question but... audio is not my favourite subject and I don't know anything about audio.

    [ Edited by MDW 18.12.2019 - 20:01 ]
  • »18.12.19 - 19:13
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Minuous
    Posts: 161 from 2010/2/13
    No need for Reggae: AmiArcadia can do all the things on your list and uses AHI (relevant code is in aa-sound.c), which is a more portable solution.

    [ Edited by Minuous 19.12.2019 - 06:06 ]
  • »18.12.19 - 19:56
    Profile Visit Website
  • MDW
  • Order of the Butterfly
    Order of the Butterfly
    MDW
    Posts: 451 from 2003/7/26
    From: Wroclaw/Poland
    Quote:

    Minuous wrote:
    No need for Reggae: AmiArcadia can do all the things on your list and uses AHI, which is a more portable solution.

    Reggae looks quite good. :) However I can learn AHI... Should I use high-level or low-level AHI interface?

    [ Edited by MDW 18.12.2019 - 20:01 ]
  • »18.12.19 - 20:00
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Minuous
    Posts: 161 from 2010/2/13
    The high-level interface is adequate for most needs; I'd suggest having a quick read of the AHI documentation first which discusses the pros and cons of each before starting coding.

    [ Edited by Minuous 19.12.2019 - 06:15 ]
  • »18.12.19 - 21:05
    Profile Visit Website
  • MDW
  • Order of the Butterfly
    Order of the Butterfly
    MDW
    Posts: 451 from 2003/7/26
    From: Wroclaw/Poland
    Quote:

    Minuous wrote:
    I'd suggest having a quick read of the AHI documentation first which discusses the pros and cons of each before starting coding.

    Yes, this is very good idea. 👍 I have started reading the documentation and analysing simple examples.

    I can't find whether AHI allows to play a sound with specified number of loops. Does AHI contains this feature or I should implement looping in my code?

    If I decided to AHI API, I'd had to implement loading sound files (e.g. WAVE). In case of Reggae I don't have to do it.

    [ Edited by MDW 19.12.2019 - 12:00 ]
  • »18.12.19 - 21:57
    Profile Visit Website
  • MDW
  • Order of the Butterfly
    Order of the Butterfly
    MDW
    Posts: 451 from 2003/7/26
    From: Wroclaw/Poland
    Quote:

    Minuous wrote:
    AmiArcadia can do all the things on your list and uses AHI (relevant code is in aa-sound.c), which is a more portable solution.

    What do you think about playing sounds using a sound DataTypes? It allows to loading, playing and it is portable between all Amiga-like systems.

    [ Edited by MDW 21.12.2019 - 20:35 ]
  • »21.12.19 - 20:34
    Profile Visit Website
  • MorphOS Developer
    zukow
    Posts: 642 from 2005/2/9
    From: Poland
    For me, use reggae to load samples.
  • »21.12.19 - 22:14
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Minuous
    Posts: 161 from 2010/2/13
    If the datatypes system has enough functionality for you then you may as well use that. Although parsing a WAV file is pretty straightforward really.

    There are various AHIP_Loop#? tags that can be used to control looping in AHI.
  • »22.12.19 - 00:15
    Profile Visit Website
  • MDW
  • Order of the Butterfly
    Order of the Butterfly
    MDW
    Posts: 451 from 2003/7/26
    From: Wroclaw/Poland
    Quote:

    zukow wrote:
    For me, use reggae to load samples.

    I probably use Reggae for loading and playing sound. This is more elegant than AHI API and implement loading e.g. WAVE file. And I can play music in mpeg audio.

    [ Edited by MDW 22.12.2019 - 21:21 ]
  • »22.12.19 - 00:41
    Profile Visit Website
  • MDW
  • Order of the Butterfly
    Order of the Butterfly
    MDW
    Posts: 451 from 2003/7/26
    From: Wroclaw/Poland
    Quote:

    Minuous wrote:
    If the datatypes system has enough functionality for you then you may as well use that. Although parsing a WAV file is pretty straightforward really.

    I have tried to play WAVE, MP3 files using standard datatypes from MorphOS. It works very good. However I can only PLAY and STOP sound(s). After PAUSE a sound, RESUME doens't resumed the sound.

    I think I will back to AHI or Reggae. Currently I am not going to create versions for other Amiga-system. Only MorphOS.

    Quote:

    There are various AHIP_Loop#? tags that can be used to control looping in AHI.

    Yes, there are 6 AHIP_Loop... I will check it.
  • »22.12.19 - 00:49
    Profile Visit Website
  • MDW
  • Order of the Butterfly
    Order of the Butterfly
    MDW
    Posts: 451 from 2003/7/26
    From: Wroclaw/Poland
    Minuous, zukow:

    I have one question. I load a 16-bit stereo sample using sound datatype, check type of the sample (function GetDTAttrs with tag SDTA_SampleType). Returned type is 0x00020002, so this is really stereo 16-bit:

    soundclass.h
    Code:
    #define SDTST_M8S  0x00010001 /* 8bit mono sample (default) */
    #define SDTST_S8S 0x00020001 /* 8bit stereo sample (samplewise left/right) */
    #define SDTST_M16S 0x00010002 /* same as SDTST_M8S but 16bit */
    #define SDTST_S16S 0x00020002 /* same as SDTST_S8S but 16bit */


    However if I play the sound using AHI with parameter:
    Code:
    AHIio->ahir_Type = AHIST_S16S;

    tempo of the sound is too fast (probably 4x).
    If I set parameter:
    Code:
    AHIio->ahir_Type = AHIST_M8S;

    tempo of ths sound is correct.

    What does it mean? Sound loaded using DataTypes always is converted to 8-bit?

    If this is true, sound datatypes are absolutely useless. :) Now I understand why Reggae was created. :)
  • »22.12.19 - 15:00
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Minuous
    Posts: 161 from 2010/2/13
    IIRC datatypes are always converted internally to an IFF representation. For sound files this would be 8SVX, even though there do exist IFF formats for storing 16-bit sound (eg. 16SV, AIFF).
  • »22.12.19 - 15:26
    Profile Visit Website
  • MDW
  • Order of the Butterfly
    Order of the Butterfly
    MDW
    Posts: 451 from 2003/7/26
    From: Wroclaw/Poland
    Quote:

    Minuous wrote:
    IIRC datatypes are always converted internally to an IFF representation. For sound files this would be 8SVX, even though there do exist IFF formats for storing 16-bit sound (eg. 16SV, AIFF).

    Thank you for the clarification. :) So I won't use DataTypes. In case of sound this is useless on NextGen Amiga-like systems.
  • »22.12.19 - 15:30
    Profile Visit Website