Solved

MP3 Stream to PCM Stream using ACM in VB.Net

Posted on 2004-09-15
24
1,435 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 10
24 Comments
 
LVL 18

Expert Comment

by:armoghan
ID: 12065203
0
 
LVL 4

Author Comment

by:w3tim
ID: 12082479
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
ID: 12110143
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!

 
LVL 18

Expert Comment

by:armoghan
ID: 12110420
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12110463
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
ID: 12110467
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
ID: 12110475
Sorry, didn't get the last message until i wrote mine.  Will try that!
0
 
LVL 4

Author Comment

by:w3tim
ID: 12110564
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
ID: 12110732
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
ID: 12110750
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
ID: 12111267
0
 
LVL 4

Author Comment

by:w3tim
ID: 12113572
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
ID: 12190230
Still not getting anywhere with this.  If anyone can help... Please!
0
 
LVL 4

Author Comment

by:w3tim
ID: 12345401
Can anyone help!?
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12345448
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
ID: 12345472
something like this
System.Diagnostics.Process.Start( "test.exe", parameters );
0
 
LVL 4

Author Comment

by:w3tim
ID: 12345496
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
ID: 12345592
>>>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
ID: 12345639
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
ID: 12345749
0
 
LVL 4

Author Comment

by:w3tim
ID: 12345780
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
ID: 12345786
Wish you best of luck in your quest :)
0
 
LVL 4

Author Comment

by:w3tim
ID: 12582161
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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 - SQL Timeout 9 50
Create a datatable in vb.net dynamically 1 39
VB.Net. Reading xml value 6 38
VB.NET Inline If statement 4 40
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 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