MP3 Stuff-VBForums
Results 1 to 30 of 30

Thread: MP3 Stuff

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,720

    Question MP3 Stuff

    Hello....

    Is there a DLL or OCX, that you can give a buffer (WAV Data) and converts it to an MP3 buffer ? and vice versa ?

    I need it to be done in memory (with buffers), I want to do a voice chat program..... so nothing is done on the disk...

    Tanks in advance

  2. #2
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375
    So are you saying you want the program to change a wav sequence into a mp3 sequence as it is being said and not save anything onto the computer?
    -Show me on the doll where the music touched you.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,720
    I have programs that convert a WAV file to MP3, but when I have to send over the internet every second, and every time to make a WAV file for only one second and then convert to another file MP3, it too much processing, too many files, and too slow....

    I want to give to a DLL(let say), a pointer to the WAV data, the DLL converts the data to MP3 and returns a pointer to the new buffer, then I can send the buffer over the internet to the person I'm chatting with.... (and there the reverse is done)

    Maybe there are OCX, or DLL files that do ALL that, but I want only the converting part because I want to throw in an encription algoritm before sending the data (I know how to do that)

    All I need is something that convers to mp3 and vice versa in memory....

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,720
    Someone.... please...... help !

  5. #5
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    Please, if you find this Dll, please contact me, I really need this kind of dll. I'll contact you if I find One.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,720

    I FOUND IT !!!

    I FOUND IT !!!

    Yup, finally...

    It's a DLL, as I was hoping, It's called BladeEnc.DLL (Blade Encoder DLL). BUT it works only in C/C++, I don't know why it does not work in Visual Basic... (I could not get it to work...)

    But I got around it, of course, I made another DLL, in MFC that is using the BladeEnc.DLL, and this one can be included in Visual Basic.

    First of all, here is the link where I found the original DLL....
    http://www.rocketdownload.com/supfiles.htm

    I attached my source code for the DLL(that uses BladeEnc.DLL), a BAS file so you can use my DLL in Visual Basic, and a CLS, to make your life a little easier . The code is not very good, but it's a start

    So, let's recap.
    The CLS uses the BAS, the BAS uses the BladeEncVB.DLL, and BladeEncVB.DLL uses the BladeEnc.DLL....

    If your wandering if it affects the speed passing values from one to the other, then the other, and so on.... I say ... NO, not really... If you notice, every time it's passing pointers (4 Bytes for each parameter), so, that should not slow down the encoding part even if the buffer is very long, it only passes 4 bytes (it's pointer)

    Also, you will notice a new function I made, ChangeSoundVolume and ChangeSoundVolumeB, both of them are for 16 Bit WAV buffer, just the way you pass the data is different. Visual Basic is slow on loops, that's why I made it in the BladeEncVB.DLL

    OK, NOW !
    I have another problem

    ANYONE find the same thing but to DECODE !
    (To decode in memory like this DLL...)


    PS: I noticed this thread has top rating, I wander how it will be after this post


    If anyone makes improvements to my code, please post the code here, Thanks...
    Attached Files Attached Files

  7. #7
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    Thank you for your Dll. I will try it as soon as possible.
    I don't know C/C++, but i see you do so have a look at this file, maybe it can help you.
    I've got other files that could help but bigger than 100 Ko. Can you send me your email please cause i don't remember where i download them.
    Attached Files Attached Files

  8. #8
    Lively Member formulav8's Avatar
    Join Date
    Mar 2002
    Location
    Orlando
    Posts
    108
    I have a mp3 encoding example on my website. I didn't make the dll so I don't know if it encodes in memory or not. Couldn't hurt to try it out I guess. I saw a couple examples at planetsourcecode using a c++ dll to decode a mp3 to a wave file. Again I don't know if it does it in memory or not.


    Jason

  9. #9
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82

    Cool

    The Dll you've made is just great. It works well, I can code in mp3. Only one thing, I don't know why, but i can't get access to your event MP3buffer(Buffer() as byte). One other thing is that i don't know why when outputing to a file the end of the file is just no sound but what i encoded is perfect. (I recorded 8s via DSound8 : 8s perfect then 8s nosound).
    Thank you for all
    Hope you'll find the other way (mp3->wav).

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,720
    to get the event working, do this in your form...

    Code:
    ' General Declarations...
    Private WithEvents BEncoder As BladeEncoder
    
    Private Sub Form_Load()
        Set BEncoder = New BladeEncoder
    End Sub
    
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        Set BEncoder = Nothing
    End Sub
    And to fix the problem with the second buffer not being correct you need to make the DirectX buffer a multiple of BEncoder.Samples and to make sure the buffer is aligned (divizible by 4)

    Code:
    Private Sub DirectXEvent8_DXCallback(ByVal eventid As Long)
        Dim DataBuff() As Byte
        ReDim DataBuff(HBuffer - 1)
        
        Select Case eventid
        Case StartEvent
            gDSCB.ReadBuffer HBuffer, HBuffer, DataBuff(0), DSCBLOCK_DEFAULT
        Case MidEvent
            gDSCB.ReadBuffer 0, HBuffer, DataBuff(0), DSCBLOCK_DEFAULT
        Case EndEvent
            BEncoder.CloseStream
        End Select
        
        If eventid = StartEvent Or eventid = MidEvent Then
           ' write to file...
        End If
    End Sub
    
    ' when you initialize your DirectX sound do this
    Private Sub Initialize()
        ... declarations.....
    
       ' you must call BEncoder.InitStream before this line
        HBuffer = BEncoder.Samples * 8
        HBuffer = HBuffer + (HBuffer Mod wFormat.nBlockAlign)
        BufferSize = HBuffer * 2
    
        With dscBuf
            .fxFormat = wFormat
            .lBufferBytes = BufferSize
            .lFlags = DSCBCAPS_DEFAULT
        End With
        
        Set gDSCB = gDSC.CreateCaptureBuffer(dscBuf)
        
        ReDim dsbpn(0 To 2) As DSBPOSITIONNOTIFY
        
        StartEvent = gDX.CreateEvent(Me)
        With dsbpn(0)
            .hEventNotify = StartEvent
            .lOffset = 1
        End With
        
        MidEvent = gDX.CreateEvent(Me)
        With dsbpn(1)
            .hEventNotify = MidEvent
            .lOffset = HBuffer
        End With
        
        EndEvent = gDX.CreateEvent(Me)
        With dsbpn(2)
            .hEventNotify = EndEvent
            .lOffset = DSBPN_OFFSETSTOP
        End With
        gDSCB.SetNotificationPositions 3, dsbpn()
        
        gDSCB.Start DSCBSTART_LOOPING
    End Sub

  11. #11
    Lively Member formulav8's Avatar
    Join Date
    Mar 2002
    Location
    Orlando
    Posts
    108
    Your putting alot of work into this. If you want to share it I would put it on my website. Giving you the credit of course.


    Jason

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,720
    I would want to share the program i'm working on (SoundBroadcast), but I don't really want to share the code at this point, it's too messy... lot's of functions that are not used... it's not comented at all.... (I hate that ), I don't need coments for myself...

    The initial code was only for recording sound to a wave file, and I modified the project to compress to mp3, then to send to whomever is connected to the program...

    But the program itself (compiled) is pretty good....

    It's basicly like a Shouthcast server.... except this one is sending what you curently have on you sound card... if windows makes a sound, or if ICQ is on, or something like that... the people connected hear whatever you hear on your sound card hehe, and oviously, if the micrphone is on, you can also talk in it, and they will hear it.... (That's how I really wanted to do), then I discovered that it works for all sounds....

    Well... I think it depends on the sound card also.... with mine i can set it to "what you hear", or a specific input... like wave, midi, mic., etc.

    Anyways....

    If you want to put the Setup program on your web-page, just tell me, and i'll make the setup, and i'll put it on MY web-page (probaly it's about 3 - 4 Megs) so you can download it.... (I don't have any hits on my web-page...)

  13. #13
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    The code you send doesn't work on my computer, the sound is awful. Can you send me the whole code Please.

  14. #14
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82

    Cool It works

    I change your class module just in one line this one :
    DSamples = DSamples - (TSamples)

    by

    DSamples = DSamples - (TSamples * 2)

    in the encodeChunk function.

    Now it works very well and i don't have to care about the buffer size.

    Thank you for your Dll a lot, it's great.

  15. #15
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82

    Smile New encoder Dll

    I found another dll that works for encoding like bladeenc.dll.
    It's lame_enc.dll
    you can find it there : http://www.jthz.com/~lame/
    It uses the same functions that bladeenc.dll so I just rebuild your C/C++ project changing the name of the library to load.
    I think the sound quality is better.

    I hope you can do a decoder soon.

  16. #16

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,720
    I'm trying for days to get the mpglib.dll to work, but it crashes everytime I try to decode.... I think the DLL is accessing memory outside of the array I pass it to....

    Well.... if anyone finds a DLL to decode for MP3, even if it's in C/C++, please post a message where i can get it from.... I will write the code so it can be used in VB.....

  17. #17
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    Can you send me what you've done with the mpglib.dll please ?

  18. #18

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,720
    Originally posted by matt3011
    Can you send me what you've done with the mpglib.dll please ?
    But it will crash your VB....

  19. #19
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    I don't care, I want to try before saying we can't do anything with it.
    If it crashes VB, no matter, you restart VB. It won't crash my computer.

  20. #20
    Lively Member formulav8's Avatar
    Join Date
    Mar 2002
    Location
    Orlando
    Posts
    108
    Send it my way also and I will help you work it out.

  21. #21

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,720
    I wanted to make a DLL for both Encode and Decode, but the decode crashes when I use the function DecDecodeChunk (decodeMP3 in DLL). It does not crash the first time I call it, but after 2 to 5 calls.... I named the functions (for VB) different so there is an obvious distinction between encode functions, and decode functions...

    I have Windows 2000, so my windows does not crash, but if you have Windows 98, 95 I think it will crash windows too...

    From mpglibdll.h
    WARNING: If decodeMP3 returns MP3_ERR you should instantly reinitialize the mpglib. Otherwise it could crash. Originally the mpglib exits if a heavy error occurs. This is disabled in the mpglib.dll (#define BE_QUIET) to force playback of corrupted MP3 files.
    I don't really like the sound of that....

    When I try to decode, the decodeMP3 function returns MP3_ERR every time after the first call....


    By the way.... the Lame Encoder.... I looked on the net for example code in C/C++, and I could not find any, but I looked in the DLL, and it has a couple more functions, and it seems that it can do more than just encoding.... but not sure since I don't any samples how to use it....

    I'm thinking to add in InitializeEncodeDLL a parameter to what DLL you want to use. I did not do that yet, since I don't know for sure how to use it.
    Last edited by CVMichael; May 16th, 2002 at 02:57 AM.

  22. #22
    Lively Member formulav8's Avatar
    Join Date
    Mar 2002
    Location
    Orlando
    Posts
    108
    If you want I have a nice mp3 encoder someone made in vb that uses the lame dll. I don't remember his name but I downloaded it from planet source code. I don't know if it is still their or not. LMK and I could put it on my webpage and give you a link to download it from.



    Jason

  23. #23

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,720
    Sure... Only if you have the code....

  24. #24
    Lively Member formulav8's Avatar
    Join Date
    Mar 2002
    Location
    Orlando
    Posts
    108
    Of course I have the code. Let me find it.

  25. #25
    Lively Member formulav8's Avatar
    Join Date
    Mar 2002
    Location
    Orlando
    Posts
    108
    [edit]

    Ok I'm assuming you got it downloaded. I removed the link for bandwidth reasons. BTW your welcome



    Jason
    Last edited by formulav8; May 12th, 2002 at 01:56 PM.

  26. #26
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    Something New ?

  27. #27
    Lively Member formulav8's Avatar
    Join Date
    Mar 2002
    Location
    Orlando
    Posts
    108
    You talking to me or him?

  28. #28

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,720
    Well, if your talking to me.....

    No, nothing new...

    I've looked over the net for days, and nothing.... most of the decode DLLs i found I can't get them to work.... lots and lots of errors and crashes.... and all kinds of weird stuff

    And mpglib.dll, I still did not get it to work... keeps crashing my VB

    You were saying that you are gonna look at my attempts to make it work..... Did you had any success ?
    Last edited by CVMichael; May 16th, 2002 at 02:55 AM.

  29. #29
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    I didn't make it work. Even if I just Send one frame of the mp3file, it crashes.

  30. #30
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    Have a loof at www.fmod.org. I'm sure something can be done with tis dll.
    I didn't look so far at the moment. So, I don't know how it works, I've just look the examples in VB. They don't use in memory translation but I'm sure this can be done.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.