Author Topic: Looping music  (Read 239 times)

QuentinC

  • Posts: 39
Looping music
« on: 12 Sep '17 - 18:02 »
Hello,

I hope this question isn't too vague and too off-topic.

My goal is to loop music streams, at predefined loop points, not necessarily from beginning to end.
The question isn't on how to do it technically, as it is explained in the documentation.
To do it, you can set a sync on the loop end position, and then use BASS_ChannelSetPosition in the sync callback to put back the playing position to the loop start point.
I already tried it and it works fine.

My question is rather how is this usually done so that the developer hasn't to programatically define and ahrd-code the loop start and end points; because this is normally the role of the sound/music designer and not the developer.

I assume the sound/music designer edit his music in a software like audacity, set the loop points by setting markers, and they are saved in the file.
Then I should be able to obtain this metadata and set up the loop accordingly.

What should I use to get that metadata ?
BASS_ChannelGetTags or something else ? Which tag format ? What kind of string should I look for ?
Is there a standard for this or everybody is doing it a little differently ?

More precisely, is it possible to save loop start/end point metadata in an OGG file like I describe ?
IF not, which other common lossy format does permit it ?
I would prefer avoid WAV and flac.


Thank you for your answers

saga

  • Posts: 2183
Re: Looping music
« Reply #1 on: 12 Sep '17 - 22:07 »
Both Ogg Vorbis and FLAC use Vorbis tags (BASS_TAG_OGG) for metadata tagging. One "unofficial" (but still supported by a small number of applications) way of storing loop points in Vorbis tags is the LOOPSTART and LOOPLENGTH tags, e.g. "LOOPSTART=3" and "LOOPLENGTH=1000" for a loop that goes from frame 3 to 1003. These tags can be manually created with any tagging software that allows writing of arbitrary Vorbis tags (such as MP3Tag).
Alternatively, FLAC files can contain "foreign" tags, which could be a "smpl" chunk as found in WAV files, but these are more complicated to write and less software probably supports them. WAV is certainly the easiest when it comes to loop tags, because most audio editing software directly supports WAV loop points. So if you start out with WAV files and convert them to Ogg later, you could parse the "smpl" chunk and convert it to LOOPSTART/LOOPLENGTH tags for the Ogg file.

QuentinC

  • Posts: 39
Re: Looping music
« Reply #2 on: 13 Sep '17 - 08:18 »
Thank you.

Is there a way to convert from OGG frames to time or bytes, so that I can put the retrieved values into BASS_ChannelSetSync and BASS_ChannelSetPosition ?
I don't see anything in the documentation.

saga

  • Posts: 2183
Re: Looping music
« Reply #3 on: 13 Sep '17 - 10:40 »
Sorry, by frames I meant sample frames (or sampling points), not Ogg frames.

QuentinC

  • Posts: 39
Re: Looping music
« Reply #4 on: 13 Sep '17 - 13:59 »
Ah OK ! It's much easier then.
Thank you.