Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1509
  • Last Modified:

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
0
w3tim
Asked:
w3tim
  • 13
  • 10
1 Solution
 
armoghanCommented:
0
 
w3timAuthor Commented:
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
0
 
w3timAuthor Commented:
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
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
armoghanCommented:
0
 
armoghanCommented:
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
0
 
w3timAuthor Commented:
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
0
 
w3timAuthor Commented:
Sorry, didn't get the last message until i wrote mine.  Will try that!
0
 
w3timAuthor Commented:
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!?
0
 
armoghanCommented:
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
0
 
w3timAuthor Commented:
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.

0
 
w3timAuthor Commented:
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
0
 
w3timAuthor Commented:
Still not getting anywhere with this.  If anyone can help... Please!
0
 
w3timAuthor Commented:
Can anyone help!?
0
 
armoghanCommented:
Another simple option could be use this command line converter and use it through your code
http://www.codeproject.org/audio/madlldlib.asp
0
 
armoghanCommented:
something like this
System.Diagnostics.Process.Start( "test.exe", parameters );
0
 
w3timAuthor Commented:
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!
0
 
armoghanCommented:
>>>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.

0
 
w3timAuthor Commented:
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
0
 
armoghanCommented:
0
 
w3timAuthor Commented:
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
0
 
armoghanCommented:
Wish you best of luck in your quest :)
0
 
w3timAuthor Commented:
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
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 13
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now