Solved

MP3 Stream to PCM Stream using ACM in VB.Net

Posted on 2004-09-15
24
1,407 Views
Last Modified: 2008-03-10
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
Comment
Question by:w3tim
  • 13
  • 10
24 Comments
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
0
 
LVL 4

Author Comment

by:w3tim
Comment Utility
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
 
LVL 4

Author Comment

by:w3tim
Comment Utility
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
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
0
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
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
 
LVL 4

Author Comment

by:w3tim
Comment Utility
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
 
LVL 4

Author Comment

by:w3tim
Comment Utility
Sorry, didn't get the last message until i wrote mine.  Will try that!
0
 
LVL 4

Author Comment

by:w3tim
Comment Utility
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
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
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
 
LVL 4

Author Comment

by:w3tim
Comment Utility
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
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 4

Author Comment

by:w3tim
Comment Utility
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
 
LVL 4

Author Comment

by:w3tim
Comment Utility
Still not getting anywhere with this.  If anyone can help... Please!
0
 
LVL 4

Author Comment

by:w3tim
Comment Utility
Can anyone help!?
0
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
Another simple option could be use this command line converter and use it through your code
http://www.codeproject.org/audio/madlldlib.asp
0
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
something like this
System.Diagnostics.Process.Start( "test.exe", parameters );
0
 
LVL 4

Author Comment

by:w3tim
Comment Utility
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
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
>>>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
 
LVL 4

Author Comment

by:w3tim
Comment Utility
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
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
0
 
LVL 4

Author Comment

by:w3tim
Comment Utility
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
 
LVL 18

Accepted Solution

by:
armoghan earned 500 total points
Comment Utility
Wish you best of luck in your quest :)
0
 
LVL 4

Author Comment

by:w3tim
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now