19 Jun '13 - 03:02 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: BASS_SYNC_META request  (Read 424 times)
Bert B.
Posts: 103


« on: 3 Aug '12 - 12:46 »
Reply with quoteQuote

Hello Ian,

Somewhere in these forums you wrote:

Quote
A BASS_SYNC_META sync will be triggered as soon as metadata is received from the server

This is also stated in the documentation.

Would it be possible to make some change in Bass so that BASS_SYNC_META is triggered at the moment that the file is actually being played (assuming that the meta data is sent at the start of a file)?

Regards,
Bert
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #1 on: 3 Aug '12 - 15:35 »
Reply with quoteQuote

Is the aim to have a META sync delayed until its position in the audio data is heard? If so, I think it would be possible to get close with MP3, but not with AAC as BASS doesn't know about the decoding of that, ie. it wouldn't know what the metadata's position in the encoded data will translate to in the decoded data.

Also note that metadata is not necessarily sent in sync by the server (it's very unlikely to be in sync due to the way that metadata is sent at fixed intervals), eg. a metadata change may not be in time with a song change. So even if a META sync is triggered at the time that the surrounding audio is heard, it may still not appear to be in sync.
Logged
Bert B.
Posts: 103


« Reply #2 on: 3 Aug '12 - 15:49 »
Reply with quoteQuote

Hi Ian,

Quote
Is the aim to have a META sync delayed until its position in the audio data is heard?
Yes.

No problem if the functionality is limited to MP3.

Quote
Also note that metadata is not necessarily sent in sync by the server (it's very unlikely to be in sync due to the way that metadata is sent at fixed intervals)
Do you know how much this can vary?

Bert
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #3 on: 3 Aug '12 - 17:09 »
Reply with quoteQuote

The metadata interval can be set in the server config (and is sent to the client in the "icy-metaint" header), so it varies but it's generally somewhere between 16KB and 32KB. At a bitrate of 128kb/s, that equates to 1-2 seconds.

If you would like to try accounting for the buffered data to delay processing the metadata yourself, you could try something like this...

QWORD encoded=BASS_StreamGetFilePosition(stream, BASS_FILEPOS_DOWNLOAD)
-BASS_StreamGetFilePosition(stream, BASS_FILEPOS_CURRENT); // buffered encoded data
DWORD decoded=BASS_ChannelGetData(stream, 0, BASS_DATA_AVAILABLE); // buffered decoded data
double delay=BASS_ChannelBytes2Seconds(stream, decoded)+(double)encoded/bitrate; // total delay (bitrate=bytes/sec)
Logged
Bert B.
Posts: 103


« Reply #4 on: 14 Aug '12 - 15:07 »
Reply with quoteQuote

Thanks Ian,

Maybe you can add the code to the examples listed under BASS_ChannelSetSync.

Bert
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #5 on: 14 Aug '12 - 16:56 »
Reply with quoteQuote

Actually, that code could perhaps be expanded to use a BASS_SYNC_POS sync to delay the metadata processing, something like this..

QWORD buffered=BASS_StreamGetFilePosition(stream, BASS_FILEPOS_DOWNLOAD)
-BASS_StreamGetFilePosition(stream, BASS_FILEPOS_CURRENT); // buffered encoded data
QWORD delay=BASS_ChannelSeconds2Bytes(stream, (double)buffered/bitrate); // translate it to decoded data (bitrate=bytes/sec)
QWORD pos=BASS_ChannelGetPosition(stream, BASS_POS_BYTE|BASS_POS_DECODE); // get current decoding position
BASS_ChannelSetSync(stream, BASS_SYNC_POS|BASS_SYNC_ONETIME, pos+delay, MetaDelaySyncProc, 0); // set a sync after the delay

...

void CALLBACK MetaDelaySyncProc(HSYNC handle, DWORD channel, DWORD data, void *user)
{
const char *meta=BASS_ChannelGetTags(channel, BASS_TAG_META); // get the metadata
// process it...
}
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines