18 Jun '13 - 08:32 *
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: Play specified piece of mp3 file (from second to second)  (Read 288 times)
margor
Posts: 1


« on: 1 Jun '12 - 22:59 »
Reply with quoteQuote

Hello,
I don't have idea how to solve the following problem:

1. I need to play mp3 file, but it is necessary to start at the specified second. For example,  I want to play only from 10th second to 16th second of mp3 file.
What is the simplest way to achieve this?  Is is possible to use BASS_StreamCreate function? I tried to modify offset and length, but it failed (I broken mp3). Or it is necessary to use BASS_SampleCreate.

2. When I cope with point 1. I'd like to join two pieces of mp3 files. I would appreciate any advice to do this (clue).

Thank you for your attention.

Logged
Samsa
Posts: 2


« Reply #1 on: 1 Jun '12 - 23:21 »
Reply with quoteQuote

After creating your stream and before play it, seek and set a sync position (C# sample):

...
int mBeforeEndHandle = 0;
SYNCPROC beforeEndProc = new SYNCPROC(BeforeEnd);
...
Bass.BASS_ChannelSetPosition(stream, startTimeInSeconds/*double*/)
long pos = Bass.BASS_ChannelSeconds2Bytes(stream, stopTimeInSeconds/*double*/);
mBeforeEndHandle = Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_POS, pos, beforeEndProc, new IntPtr(0));
...



void BeforeEnd(int handle, int channel, int data, IntPtr user)
{
    if (handle == mBeforeEndHandle ){
        Bass.BASS_ChannelRemoveSync(channel, mBeforeEndHandle);
        // Stop stream
        // Free stream if needed
    }
}
...
« Last Edit: 1 Jun '12 - 23:25 by Samsa » Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines