22 May '13 - 03:57 *
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: Audio stream for remote playback?  (Read 553 times)
vbguyny
Posts: 5


« on: 28 Aug '12 - 17:20 »
Reply with quoteQuote

Is there a sample or can someone please provide me some code which I can use to capture the raw bytes of the audio which is playing on the default playback device?

This is what I have so far in my spec:

1. Detect if there is any audible volume on the default play back device
2. Start recording the audio from the default device using the BASS Enc routines.
3. After 100-200ms, send the buffer to the remote server. *
4. Play back the audio on the client side. *

I need help with items 3 and 4 above.  I know how to transfer raw bytes over the  network so you don't need to include that in the sample.

Thanks,
-Mike

Logged
fmcoder
Posts: 386


« Reply #1 on: 28 Aug '12 - 20:14 »
Reply with quoteQuote

For 3 you can use BASSenc addon, see the BASS_Encode_CastInit function. It will connect to Shoutcast/Icecast server and sent stream. If you don't want to use 3rd party servers, you can use a server integrated intom bass - BASS_Encode_ServerInit.

To play it on client side use the BASS_StreamCreateURL function.
Logged
vbguyny
Posts: 5


« Reply #2 on: 29 Aug '12 - 04:42 »
Reply with quoteQuote

@fmcoder: Thanks for your reply.  I should have mentioned that I already looked into implementing a Ice/shoutcast but the issue is that buffering is involved and I want this to have the least amount of lag as possible.
Logged
Ian @ un4seen
Administrator
Posts: 15259


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

Are you encoding the data, and if so, what encoder/format are you using? Regarding latency, you may have a problem achieving very low latency with an external encoder (via BASS_Encode_Start) due to the encoded data being received in blocks (generally of 4KB). So, if you need low latency, you may have more joy with an ACM codec (via BASS_Encode_StartACM), or building the encoder into your app (or a DLL) and feeding it sample data via a DSP function (see BASS_ChannelSetDSP).

If you are implementing the network code yourself, then you can use BASS_StreamCreateFileUser to decode/play the data on the receiving end; you would use the buffered file system in that, eg. STREAMFILE_BUFFER (or STREAMFILE_BUFFERPUSH).
Logged
vbguyny
Posts: 5


« Reply #4 on: 30 Aug '12 - 02:38 »
Reply with quoteQuote

@Ian: I am encoding the data using lame for MP3 and oggenc for OGG.  Basically I need the audio in these formats for playback in a web browser.

Could you please point me to some samples written in VB6 that use the BASS_Encode_StartACM to encode and MP3 and OGG file?

As for BASS_StreamCreateFileUser, but I think that is for playback only.  I will not have access to BASSWASAPI form the receiving end.

-Mike
Logged
Ian @ un4seen
Administrator
Posts: 15259


« Reply #5 on: 30 Aug '12 - 14:11 »
Reply with quoteQuote

I'm not sure if there is an OGG ACM codec available. Windows does come with an MP3 ACM codec, but that is limited to a sample rate of 22050 Hz. If that's fine, you can use it something like this...

DWORD formlen=BASS_Encode_GetACMFormat(0, NULL, 0, NULL, 0); // get suggested ACM format buffer size
void *form=malloc(formlen); // allocate the format buffer
formlen=BASS_Encode_GetACMFormat(channel, form, formlen, NULL,
    MAKELONG(BASS_ACM_SUGGEST|BASS_ACM_RATE|BASS_ACM_CHANS, WAVE_FORMAT_MPEGLAYER3)) // get MP3 format info (remove BASS_ACM_SUGGEST to let user choose)
BASS_Encode_StartACM(channel, form, 0, EncodeProc, NULL); // set an MP3 encoder on the recording

Regarding BASS_StreamCreateFileUser, that is indeed for decoding/playback (BASSWASAPI isn't required though). You mentioned that you will be handling the network data transfer yourself. You would then need some way to decode the data on the receiving end, and using BASS_StreamCreateFileUser is the way. VB6 could be an issue though. I'm not very familiar with VB6, but I believe it isn't very multi-threading/callback friendly, and BASS_StreamCreateFileUser requires callback functions (to supply the file data). If that does turn out to be a problem, perhaps you could use VB.Net instead? Or perhaps you could use BASSenc's built-in server support via BASS_Encode_ServerInit and use BASS_StreamCreateURL on the client side?
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines