Suggestion: Looping Audio

I would like to suggest a looping audio feature in the audio part of the library of both libsdl and sdl_sound. Often, a music piece will consist of two parts, an intro plus a part which is endlessly repeated. It would be great if both the .WAV and MIDI file types could be looped such that the intro part plays, then the main part which is looped endlessly. The SDL_PauseAudio would then look something like

void SDL_PauseAudio(int pause_on, int repeat_start);

Olaf–
Get your free email from www.linuxmail.org

Powered by Outblaze

I would like to suggest a looping audio feature in the audio part of
the library of both libsdl and sdl_sound. Often, a music piece will
consist of two parts, an intro plus a part which is endlessly
repeated. It would be great if both the .WAV and MIDI file types could
be looped such that the intro part plays, then the main part which is
looped endlessly. The SDL_PauseAudio would then look something like

void SDL_PauseAudio(int pause_on, int repeat_start);

This wouldn’t be feasible inside SDL itself, since it would need to retain
the entire waveform…which can be upwards of ten megabytes of data per
minute of audio (if not more).

SDL_sound can do this, but not directly; when you hit the end of a sample
you are decoding, you can call Sound_Seek() and jump to the loop point and
start decoding again from there. The library doesn’t do this directly,
since it’s a trivial amount of code in your app; if you wrap
Sound_Decode() in a function that loops at the end of the sample, you can
even make this transparent to your app; it’ll just keep returning an
endless stream of looped data.

If you just want to loop the whole sound, instead of jumping to an
arbitrary point in the middle, Sound_Rewind() is more efficient in many
cases.

Alternately, for small samples like a gun shot that you want to repeat
for a machinegun sound, you can call Sound_DecodeAll() and then manage all
the looping with the full waveform in memory, which might be easier, and
is probably more efficient in the long run.

–ryan.

Olaf Beckman wrote:

I would like to suggest a looping audio feature in the audio part of the
library of both libsdl and sdl_sound. Often, a music piece will consist of
two parts, an intro plus a part which is endlessly repeated. It would be
great if both the .WAV and MIDI file types could be looped such that the
intro part plays, then the main part which is looped endlessly. The
SDL_PauseAudio would then look something like

void SDL_PauseAudio(int pause_on, int repeat_start);

Olaf

i agree, it will make background music easyer to implement

i agree, it will make background music easyer to implement

Practically speaking, this would be best added to SDL_mixer (if SDL_sound
is too low-level for your needs).

–ryan.

I would like to suggest a looping audio feature in the audio part of
the library of both libsdl and sdl_sound. Often, a music piece will
consist of two parts, an intro plus a part which is endlessly
repeated. It would be great if both the .WAV and MIDI file types
could be looped such that the intro part plays, then the main part
which is looped endlessly. The SDL_PauseAudio would then look
something like

void SDL_PauseAudio(int pause_on, int repeat_start);–
Get your free email from www.linuxmail.org

Powered by Outblaze

I didn’t know that WAV’s had an ‘intro’ part separate from the ‘main’ part.
:^/

-bill!On Fri, Oct 04, 2002 at 09:05:11AM +0100, Big Pilot wrote:

I would like to suggest a looping audio feature in the audio part of
the library of both libsdl and sdl_sound. Often, a music piece will
consist of two parts, an intro plus a part which is endlessly
repeated. It would be great if both the .WAV and MIDI file types
could be looped such that the intro part plays, then the main part
which is looped endlessly. The SDL_PauseAudio would then look
something like

void SDL_PauseAudio(int pause_on, int repeat_start);

the library of both libsdl and sdl_sound. Often, a music piece will
consist of two parts, an intro plus a part which is endlessly
repeated. It would be great if both the .WAV and MIDI file types
could be looped such that the intro part plays, then the main part
which is looped endlessly. The SDL_PauseAudio would then look
something like

.WAV Is audio. .MID Is MIDI data (I.E. NOTE data - not sound). There is
no way to mark an “intro” in a .WAV file.

–>Neil-------------------------------------------------------------------------------
Neil Bradley What are burger lovers saying
Synthcom Systems, Inc. about the new BK Back Porch Griller?
ICQ #29402898 “It tastes like it came off the back porch.” - Me

You could, however, throw in a loop that doesn’t begin at the start of
the file… Not sure how standardized that is, though. IIRC, audio apps
that support loops can read basic loop info from each other’s files.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Coming soon from VaporWare Inc…------------------------.
| The Return of Audiality! Real, working software. Really! |
| Real time and off-line synthesis, scripting, MIDI, LGPL…|
-----------------------------------> (Public Release RSN) -' .- M A I A -------------------------------------------------. | The Multimedia Application Integration Architecture |----------------------------> http://www.linuxdj.com/maia -’
http://olofson.nethttp://www.reologica.se —On Friday 04 October 2002 11:10, Neil Bradley wrote:

the library of both libsdl and sdl_sound. Often, a music piece will
consist of two parts, an intro plus a part which is endlessly
repeated. It would be great if both the .WAV and MIDI file types
could be looped such that the intro part plays, then the main part
which is looped endlessly. The SDL_PauseAudio would then look
something like

.WAV Is audio. .MID Is MIDI data (I.E. NOTE data - not sound). There
is no way to mark an “intro” in a .WAV file.

I would like to suggest a looping audio feature in the audio part of
the library of both libsdl and sdl_sound.

I don’t see what libSDL has to do with it… It doesn’t understand audio
files in any way, beyond the point of being able to load a WAV file into
a raw memory buffer.

One might argue that it would be nice if SDL could give you some more
info about the loaded wave, but then again, I think SDL_LoadWAV() should
simply be seen as a conveniency function. Use a dedicated audio file lib,
such as SDL_sound for loading your data if you need more than the very
basics.

Often, a music piece will
consist of two parts, an intro plus a part which is endlessly
repeated.

Or you could think of it as the “end-of-file action” being a jump to a
specific position, rather than stopping playback, or restarting from the
beginning. Just one part and a loop marker.

It would be great if both the .WAV and MIDI file types
could be looped such that the intro part plays, then the main part
which is looped endlessly.

AFAIK, there’s no standard way of storing loop markers in MIDI files. At
least, I haven’t found any traces of them when saving MIDI type 0 or 1
from Cakewalk. (I hope I’m missing something…)

(As to the songs in Kobo Deluxe, they simply have special text markers
that function as commands to the custom MIDI player. I can assure you
those files won’t play correctly in any sense of the word on anything
but that engine. :slight_smile:

The SDL_PauseAudio would then look
something like

void SDL_PauseAudio(int pause_on, int repeat_start);

Again, what has SDL_PauseAudio() to do with this?

Unless the SDL audio API becomes an API for communicating with pluggable
audio engines, that is. Otherwise, you just talk to the audio engine -
not SDL. (The audio engine you’re using might even decide to use some
other API than SDL for output…)

//David Olofson - Programmer, Composer, Open Source Advocate

.- Coming soon from VaporWare Inc…------------------------.
| The Return of Audiality! Real, working software. Really! |
| Real time and off-line synthesis, scripting, MIDI, LGPL…|
-----------------------------------> (Public Release RSN) -' .- M A I A -------------------------------------------------. | The Multimedia Application Integration Architecture |----------------------------> http://www.linuxdj.com/maia -’
http://olofson.nethttp://www.reologica.se —On Friday 04 October 2002 10:05, Big Pilot wrote:

.WAV Is audio. .MID Is MIDI data (I.E. NOTE data - not sound).
There

is no way to mark an “intro” in a .WAV file.

You could, however, throw in a loop that doesn’t begin at the
start of
the file… Not sure how standardized that is, though. IIRC, audio
apps
that support loops can read basic loop info from each other’s
files.

Paraphrased from the specs: WAV files can have a “cue” chunk that
contains one or more “cue points” or “markers”. Each cue point
references a specific offset within the waveform’s data array. In
conjunction with the Playlist chunk, the Cue chunk can be used to
store looping information. See also http://www.wotsit.org
Matthijs Hollemans
All Your Software
www.allyoursoftware.com

[…WAV looping…]

Paraphrased from the specs: WAV files can have a “cue” chunk that
contains one or more “cue points” or “markers”. Each cue point
references a specific offset within the waveform’s data array. In
conjunction with the Playlist chunk, the Cue chunk can be used to
store looping information. See also http://www.wotsit.org

Thanks for looking that up for me! :wink:

Well, then there shouldn’t be a problem, really. Obviously, it has to be
supported by whatever lib one wants to use for loading and playback, but
then the playlists/“multiloops” you create with your favourite wave
editing tool will Just Work ™.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Coming soon from VaporWare Inc…------------------------.
| The Return of Audiality! Real, working software. Really! |
| Real time and off-line synthesis, scripting, MIDI, LGPL…|
-----------------------------------> (Public Release RSN) -' .- M A I A -------------------------------------------------. | The Multimedia Application Integration Architecture |----------------------------> http://www.linuxdj.com/maia -’
http://olofson.nethttp://www.reologica.se —On Friday 04 October 2002 14:29, Matthijs Hollemans wrote: