Link to home
Start Free TrialLog in
Avatar of MorrisLockwood
MorrisLockwood

asked on

How do I record internet radio in a Delphi program?

I wish to build a program to record Internet radio as it streams in. I am aware that Total Recorder does this but I would like to be able to include this functionality in my Delphi program. In particular, I would like to intercept the data stream to the sound card and record it.
 
Can you help me, please

Morris
Avatar of Lukasz Lach
Lukasz Lach

use bass.dll from u4seen (http://www.un4seen.com/):

var
  RadioStream : HSTREAM;
begin
  if not BASS_Init(-1, 44100, 0, Self.Handle) then
  begin
    ShowMessage('Bass init error');
    Exit;
  end;
  BASS_Start;
  if RadioStream <> 0 then BASS_StreamFree(RadioStream);
  RadioStream := BASS_StreamCreateURL('http://somehost:8000', 0, BASS_STREAM_AUTOFREE, 'local_filename.mp3');
  if RadioStream = 0 then
  begin
    ShowMessage('Connection to host not successful');
    Exit;
  end;
  BASS_StreamPlay(RadioStream, True, 0);
end;

Form1.OnDestroy:
  if RadioStream <> 0 then BASS_StreamFree(RadioStream);
  BASS_Free;
if you need any other help with bass.dll just ask :-)
If you don't want to include a third party DLL file you can also do it in a different manner;

Simply add a HTTP component to your form (NMHTTP e.g.) and point it to host:port and tell it to get it, the mp3 stream will flow in as well, simply write it to file and you'll have the same effect but without the bass.dll requirement.

If you want to play it you can use the WMP (windows media player / directplay) stuff to play the mp3, also to avoid the bass.dll stuff.

I made a stream ripper a few days ago using the above method (without the playing as I didn't require that) but I am not at home at the moment so cannot post code for it. (Though the explanation should get u going just fine if it's what you're looking for).
Avatar of MorrisLockwood

ASKER

Dear anAKIN and WaxOr,

I tried the Bass dll with the URL : http://www.bbc.co.uk/radio/aod/radio4.shtml?fm (see http://www.bbc.co.uk/radio4 ) and got a Bass initialisation failed message.

I looked at NMHTTP but could not see how to take it forward. I would be grateful to see the code when you return home.

I think the problem  with the BBC site is that the try to restrict the receipt of the information to the RealOne Player.  I understand that the Total Recorder program intercepts the audio stream after the player and before the audio card. I assume I will have to do that.  What is your view?

Regards

Morris
My fault basically,


I assumed you meant internet radio in the sense of streaming services like shoutcast (which pretty much implemented HTTP as their means of negotiation about what to get (including some custom headers ICY does such as ICY-GENRE, etc.).

Realplayer (or Real.) has it's own protocol I am sure which would obviously have it's own little 'talk' about whether or not the client is a legitimate realplayer client or not.

So I think you're right in your assumption that you'll have to catch it somewhere in between, but I've got no experience in that myself, nor do I have the resources here at work to
a) look at Total Recorder
b) Realplayer/etc.

Some simple thoughts on it would be to have a look at code that handles sound card activity etc. as I'm sure there's something out there, maybe things with Wave playing/recording as well..

Goodluck
(p.s. IF I look into it myself and find anything posting worthy I will let you know but chances are slim.)
bass.dll records radio sent by winamp and other, not RealPlayer...
Thank you for your efforts.
Morris
ASKER CERTIFIED SOLUTION
Avatar of mattlaver
mattlaver

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you, Matt

As I mentioned in my email, it works on one of my machines but not the other.

Any help to resolve or diagnose the problem will be much appreciated

Morris
MorrisLockwood:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
Hi!
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
https://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:

Answered by: mattlaver

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

...Snehanshu
EE Cleanup Volunteer