Link to home
Start Free TrialLog in
Avatar of w3tim
w3tim

asked on

MP3 Stream to PCM Stream using ACM in VB.Net

I'm currently developing a VB.Net audio application.  I need to be able to convert an MP3 stream (and other audio streams but specifically MP3) to a PCM stream to run through DirectSound.

If anyone knows how to access and use the Audio Compression Manager in VB.Net it would be great as I have no idea how to do this!!

I don't mind using a C# .Net dll as a kind of wrapper but my knowledge of C# is limited so I'd need all the code for compiling the DLL as i doubt I'd be able to work it out.

I'd like to keep it all VB if at all possible.

Thanks,

Tim
Avatar of armoghan
armoghan
Flag of Pakistan image

Avatar of w3tim
w3tim

ASKER

Thanks for that.

I have tried it, but I'm having difficulty with the C#.  There are so many errors occuring when I've tried to re-write it in VB that it would take far too long to for me to list them all.

Let me explain, there are 2 tasks which I need to achieve.

1, I need to be able to convert an MP3 file to a PCM Wave file.

2, I need to be able to convert an MP3 stream in to a PCM wave stream and then put it straight into a DirectSound object.  I found in the C# example the DirectX handling was a little erratic and confusing.

Ideally I'd like to be able to convert Wave to MP3 too... but that's not really such a priority!

Thanks,

Tim
Avatar of w3tim

ASKER

I've increased the points to 500 as I understand this is all pretty tricky!

The C# app did work when compiled.  There was too much code outside of the component project for me to easily convert.  I managed to duplicate the code without errors in the end, however, i must have changed some things incorrectly as it still doesn't want to work.

Any and all help please!!

Thanks,

Tim
Try the following steps, They may help

download the DirectX SDk from
http://beqiraj.com/download/directx/index.asp

associate the Libraries from it to C# project

compile the project, make a DLL in C# and use it in your VB.NET application
Avatar of w3tim

ASKER

Sorry, I should have been clearer.  I did use a translater (I think I downloaded it a while ago unless it's built in) which is a plugin for for VS.Net.  It couldn't do some bits and I had to go through.

Any other suggestions!?

I've seen very little documentation/support on this.

Tim
Avatar of w3tim

ASKER

Sorry, didn't get the last message until i wrote mine.  Will try that!
Avatar of w3tim

ASKER

I'm using directSound currently to process/play my PCM files so I have the SDK installed.

Forgive my ignorance but which libraries and is it just a matter of adding in references!?
Yes I think the code should compile after just adding the references. that are what the errors I am getting .
I do not have the SDK  right now, otherwise I could have compiled and checked it
Avatar of w3tim

ASKER

Is ACM a part of DirectX though?

This is what is confusing me.  I was under the impression it was a part of windows.  I believe that directshow will do it but it probably requires a wrapper as I haven't been able to find any documentation on managed code regarding directshow.

Avatar of w3tim

ASKER

ok, good and bad news.

The DirectShow thing inspired me to have a go at it that way.  The good news is, I can play the MP3 files.  The bad news is, I have no idea how to either save the PCM stream or "take the directsound device" into existing code that i have.

This is really what I'm trying to acheive here.  I think I may be getting somewhere now.

You may (or anyone else) have a better understanding of DirectShow/DirectSound than I.  I've had a look at it, I can do things like list filters and pins etc..... All very useful I'm sure but I don't actually know what to do with these things as I have such limited experience with DirectX.

This is the code I've got to play MP3s using DirectShow etc

Add Reference "QuartzTypeLib.dll"

Imports QuartzTypeLib

Private objFilGrph As FilgraphManager = Nothing
Private objAudio As IBasicAudio = Nothing
Private objMC As IMediaControl = Nothing

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        objFilGrph = New FilgraphManager
        objFilGrph.RenderFile("audioSample.mp3")

        objAudio = objFilGrph
        objMC = objFilGrph

        objMC.Run()
End Sub
Avatar of w3tim

ASKER

Still not getting anywhere with this.  If anyone can help... Please!
Avatar of w3tim

ASKER

Can anyone help!?
Another simple option could be use this command line converter and use it through your code
http://www.codeproject.org/audio/madlldlib.asp
something like this
System.Diagnostics.Process.Start( "test.exe", parameters );
Avatar of w3tim

ASKER

hmm, that would convert the file.  I could really do with it at realtime!  Any thoughts!?

I do have uses for converting prior to playing but I could really do with being able to converting the stream!

Thanks!
>>>I could really do with it at realtime!
easiest way would be to give the user some option (button) to convert from Mp3 to WAV and WAV to MP3. cuz conversion may take some time.
and you may need to intimate user about conversion.

Avatar of w3tim

ASKER

Hmm, well I know it's possibly to convert MP3 to a PCM stream in realtime as I've seen it done.  There is some VB5 (or 6 - can't rememeber) knocking around which I never got to work, I think I messed up when converting it to Vb.Net... I might try it again actually!

There are some tasks where it cannot be up to the user, it is an application requirement so I don't really have a choice.

Any ideas would be good.  The DirectShow stuff worked to a point.  But only so far as playing the files.  As soundcards handle PCM only (usually) the data must be converted at some point, I'm assuming some directShow filter does this.  What I want to do is rather than it output the PCM data to the soundcard, I'd like to take the stream, analyse it and them pass it into DirectSound.

If anyone has any background on this or has done this before, please let me know.

Thanks
Avatar of w3tim

ASKER

Good plan, I'll try that too!

I will include you on points regardless of question being answer, all constructively intentioned help is good help!

Thanks,

Tim
ASKER CERTIFIED SOLUTION
Avatar of armoghan
armoghan
Flag of Pakistan image

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
Avatar of w3tim

ASKER

Sorry, I've had no joy and had to move on, I will return to this at another time.  For now though, yes, my intention was to award armoghan the points!

Thanks,

Tim