Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Rockbox Ports are now being developed for various digital audio players!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Implementation of clipped MP3 (begin/end) for playback of DAISY Books
« previous next »
  • Print
Pages: [1]

Author Topic: Implementation of clipped MP3 (begin/end) for playback of DAISY Books  (Read 2943 times)

Offline daniel.weck

  • Member
  • *
  • Posts: 20
Implementation of clipped MP3 (begin/end) for playback of DAISY Books
« on: September 10, 2007, 01:48:36 PM »

Hi all !

I am investigating the feasibility of porting / writing a DAISY Digital Talking Book player for Rockbox.

My Toshiba Gigabeat F60 is probably the best candidate for a full text+audio player, but I appreciate that most DAPs would be limited to audio-only books (albeit with the full Daisy navigation features).

The 2 main problematic areas are XML parsing and synchronized audio playback.

I believe that XML parsing is possible, but requires some porting effort to get rid of the dynamic malloc/free memory allocation. I am thinking about the MiniXML library, which has a small SAX event-based implementation (we don't need a full-fledge in-memory DOM document).

My immediate concern is the ability to play a portion ("clip") of an MP3 file, starting at a "begin" time and stopping at an "end" time (time offsets are relative to the beginning of the audio content).

The function "play_audio_data()" (available to plugins) takes a buffer of encoded mp3 data it seems, but I do not see how to convert a time offset to a byte offset.

I would basically want to implement something like that:

play_mp3("/books/part1.mp3", "00:00:30.0", "00:02:45.8");

Thanks for your help !
Kind regards, Dan.
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: Implementation of clipped MP3 (begin/end) for playback of DAISY Books
« Reply #1 on: September 10, 2007, 02:43:01 PM »
you might want to check how seeking to a specific position works when using bookmarks -- it's also starting playback at a given position. And passing the offset as int holding the seconds (or 10th of seconds or similar) should be much easier than passing a formatted time string.
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

Offline daniel.weck

  • Member
  • *
  • Posts: 20
Re: Implementation of clipped MP3 (begin/end) for playback of DAISY Books
« Reply #2 on: September 10, 2007, 03:06:28 PM »
Quote from: bluebrother on September 10, 2007, 02:43:01 PM
you might want to check how seeking to a specific position works when using bookmarks -- it's also starting playback at a given position.

Good idea. I found some code to restart the audio stream for the last paused position, but this was using a byte offset. I am glad to hear that bookmarks use a time-based position.

This should also help me with calculating the byte offset corresponding to the end marker.

Quote from: bluebrother on September 10, 2007, 02:43:01 PM
And passing the offset as int holding the seconds (or 10th of seconds or similar) should be much easier than passing a formatted time string.

Of course, I was just showing this example to match what a SMIL[1] player would typically do when reading DAISY content (time values would be pre-parsed on Rockbox).

[1] http://w3.org/AudioVideo
e.g.:
Code: [Select]
<audio src="./test.wav" clipBegin="npt:00:00:00.0" clipEnd="npt:00:00:50.0"/>

Thanks for your help !
Dan
« Last Edit: September 10, 2007, 04:15:07 PM by daniel.weck »
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: Implementation of clipped MP3 (begin/end) for playback of DAISY Books
« Reply #3 on: September 10, 2007, 03:38:32 PM »
Quote from: daniel.weck on September 10, 2007, 03:06:28 PM
Good idea. I found some code to restart the audio stream for the last paused position, but this was using a byte offset. I am glad to hear that bookmarks use a time-based position.
Well, I'm not sure if the code uses time offsets at all -- but I could imagine. I don't know that part of the code, so take my hints with caution.
Quote
This should also help me with calculating the byte offset corresponding to the end marker.
for CBR file this should be trivial at all anyway. I believe cuesheets work similarly by giving time offsets so that might be a good starting point as well.

Btw: your e.g. line isn't displayed properly because of the brackets -- I think that's an issue with the forum software.
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

Offline daniel.weck

  • Member
  • *
  • Posts: 20
Re: Implementation of clipped MP3 (begin/end) for playback of DAISY Books
« Reply #4 on: September 10, 2007, 03:53:14 PM »
Quote from: bluebrother on September 10, 2007, 03:38:32 PM
Well, I'm not sure if the code uses time offsets at all -- but I could imagine. I don't know that part of the code, so take my hints with caution.

I just had a look, it seems all byte-offset-based, not time-based.

see playback.c --> audio_thread() --> Q_AUDIO_PLAY --> audio_play_start((size_t)ev.data);

Quote from: bluebrother on September 10, 2007, 03:38:32 PM
for CBR file this should be trivial at all anyway. I believe cuesheets work similarly by giving time offsets so that might be a good starting point as well.

I'll now have a look at cuesheets. thx.
Logged

Offline daniel.weck

  • Member
  • *
  • Posts: 20
Re: Implementation of clipped MP3 (begin/end) for playback of DAISY Books
« Reply #5 on: September 10, 2007, 04:13:27 PM »
Quote from: daniel.weck on September 10, 2007, 03:53:14 PM
I'll now have a look at cuesheets. thx.

Ok, I found something:

plugin.c
    void (*audio_ff_rewind)(long newtime);

This seeks the currently loaded audio file to a given time position in milliseconds.

Now, to detect when the desired end time is reached, I can check the "elapsed" field of the "mp3entry" structure (for the currently playing audio file, given by audio_current_track()). I can do that in a while loop in the plugin thread (the audio thread is totally separate).

slipedit.c contains some good example code for that.

I now need to find out how to play an MP3 file from a plugin :)
Making progress...
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: Implementation of clipped MP3 (begin/end) for playback of DAISY Books
« Reply #6 on: September 10, 2007, 06:48:22 PM »
Check the codec_test plugin.
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Implementation of clipped MP3 (begin/end) for playback of DAISY Books
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.076 seconds with 14 queries.