Link to home
Start Free TrialLog in
Avatar of DukeLito
DukeLito

asked on

Read WAV, Increase Volume, Write WAV

Hi All,

I receive WAV files from another system at a set volume level (which cannot be changed - hence the problem) and then make them available for download via an ASP page.  I basically read the WAV file, and send it to the browser as a stream - which prompts the receiving computer to do a OPEN/SAVE/CANCEL dialog.

The problem I have is the WAV files are very quiet and when played via the computer they were sent to (via the ASP page) they are often not clearly audiable - even with the volume up high.

I was wondering if there was a way to create a VB class (or something that would work with ASP), that could be called from the ASP page to read the WAV file, increase it's volume, and write it again with a higher volume.

I'm guessing a VB class would probably be easiest, as it could be referenced and called from the ASP page - but I'm open to suggestions, methods and ideas here as there may well be a better way.

I'm using VB6 SP5, and classic ASP.

Thanks

Avatar of justchat_1
justchat_1

^ Thats a possibility, Im not positive ^
http://www.videohelp.com/tools?tool=BeLight


this is a free solution, increasing volkume with VB code is rather complex so why not let ASP call a commandline tool like this one? (BeLight has both a GUI and a commandline)

it has the ability to not only increase volume but also transcode
Avatar of DukeLito

ASKER

Thanks everyone, I'll look at both.

I quite like the option of calling the program from within the asp page, as this will be much easier.

How do I go about calling a third party application from within asp?  Will there be any problems with read/write/run permissions?

Thanks
u neeed to read about security issues involved with asp shelling an exe

I've now discovered how to do this, and how to avoid the pit falls along the way.  I've used the BeLight tool at http://www.videohelp.com/tools?tool=BeLight (as suggested by sakyua).

This tool is a console (DOS) based application.  Therefore it needs to be called from within the ASP page to achive my conversion, however in doing so there are some obsticles to overcome along the way - which are as follows;

1.  The directory to which BeLight/BeSweet is installed needs to have READ/WRITE/EXECUTE permissions for the IUSR (I would recommend creating a new user, assigning permissions, then under directory security running the site as the new user you just created).  Also I would recommend installing to a simple path, such as "c:\belight" as it will make calling/shelling the app within your ASP page much easier.

2.  The "c:\belight" directory must also be shared, with write permissions for everyone.  Basically, a standard shared folder.

3.  The "c:\belight" directory secuirty must allow read/write/execute for the iis user - see point 1.

4.  In my case, as my source file is on a network drive I must first copy it locally to the "c:\belight" directory, then run the conversion, then copy the new/converted version back to the network.  This is due to the fact BeLight doesn't seem to be able to see a mapped/UNC network path when called from a shell.  It probably works fine normally.  BTW, if anyone can figure this out, please let me know.

5.  Your input format of WAV (or whatever) file must be one that is compatible with BeLight - it only accepts certain formats!  Run the GUI to see what it accepts.

I think thats about it.  Anyway, I've posted the ASP code (well part of it, and then I've cut out anything sensitive) so everyone can take a look - maybe it'll help someone else in the future????  You'll have to excuse the fact the copy/paste has destroyed the formatting but if you copy/paste back into notepad you can sort it out.

The code basically does this;

- Checks the source location to see if the file has already been processed/boosted
- If not, copy the unprocessed file locally so that BeLight can process
       - BeLight is called from a shell to process the file
       - The processed file is copied back to the server
       - The processed file is sent to the users browser
- If the processed file exists, it is sent to the users browser, no conversion is done.

Lastly, I know this isn't the best or most efficient method to accomplish this but it's the best I can do in the time-scale.  Hopefully it will prove of use to someone else in the future to build on or modify.

Thanks to "sakuya_su" and "justchat_1" for their help.

Remember, stick to the code........

----------------------------------------------------------------------------------------


            ' firstly check to see if the boosted file already exists - if it does, then we don't need to convert
            ' it again, so we'll just play that one! it means this file has already been boosted/played once!
            if oFSO.FileExists("\\myserver\DATA\wavfile_BOOSTED.WAV) = true then
                  ' play the boosted one!
                  Response.ContentType = "audio/x-wav"
                              
                  With adoStream
                        .Type = 1
                        .Open
                        .LoadFromFile "\\myserver\data\wavfile_BOOSTED.WAV"
                  End With
                                    
                  Response.AddHeader "content-length",adoStream.Size
                  Response.AddHeader "Content-Disposition","attachment; filename=" & MyFilename
                  adoStream.Position = 0
                  Response.BinaryWrite adoStream.Read
                  adoStream.Close
                  Set adoStream = Nothing                  
            else
                  ' boosted one does not exist - we'll have to use the original - if it exists
                  ' check to see if original source (unboosted) file exists
                  if oFSO.FileExists("\\myserver\DATA\PMT\" & MyId & "\" & MyTel & "\msg\" & MyFilename) = true then
                              
                        ' ========= copy file from network drive to local, ready for processing
                        set TheFile=oFSO.GetFile("\\myserver\DATA\PMT\" & MyId & "\" & MyTel & "\msg\" & MyFilename)
                        TheFile.Copy "\\destserver\belight\" & MyFilename,true
                        set TheFile = nothing
            
                        ' ========================== now it's local - boost the volume of the wav                         Set oWSH = Server.CreateObject("WScript.Shell")

                        ' -- this one logs sResult = oWSH.Run("c:\belight\BeSweet.exe -core( -input " & strSpeech & "c:\belight\" & MyFilename & strSpeech & " -output " & strSpeech & "c:\belight\" & strBoostedFilename & strSpeech & " -2ch -logfile " & strSpeech & "c:\belight\" & replace(ucase(MyFilename),".WAV","") & ".LOG" & strSpeech & " -azid( -s mono -L -3db ) -ota( -hybridgain ) -ssrc( --rate 8000 ) -boost( /b=2 /l=0.95)", 1, true)
                        sResult = oWSH.Run("c:\belight\BeSweet.exe -core( -input " & strSpeech & "c:\belight\" & MyFilename & strSpeech & " -output " & strSpeech & "c:\belight\" & strBoostedFilename & strSpeech & " -2ch -azid( -s mono -L -3db ) -ota( -hybridgain ) -ssrc( --rate 8000 ) -boost( /b=2 /l=0.95)", 1, true)
      
      
                        set oWSH = nothing
                        ' ===================================================================================                        

                        ' =========== copy the boosted file back to network drive - it has `_BOOSTED.WAV` appended
                        set TheFile=oFSO.GetFile("c:\belight\" & strBoostedFilename)
                        TheFile.Copy "\\myserver\DATA\PMT\" & MyId & "\" & MyTel & "\msg\" & strBoostedFilename, true
                        set TheFile=nothing
                        ' ===================================================================================
                        
                        ' ============== delete the local boosted and local original - they exist on server =======                        
                        set TheFile=oFSO.GetFile("c:\belight\" & strBoostedFilename)
                        TheFile.delete
                        set TheFile=nothing

                        set TheFile=oFSO.GetFile("c:\belight\" & myFilename)
                        TheFile.delete
                        set TheFile=nothing
            
                        ' ===================================================================================            
                        
                        ' ========================== now stream boosted wav to user ===========================            
                        Response.ContentType = "audio/x-wav"
                              
                        With adoStream
                              .Type = 1
                              .Open
                              .LoadFromFile "\\myserver\data\pmt\" & MyId & "\" & MyTel & "\msg\" & strBoostedFilename
                        End With
                                    
                        Response.AddHeader "content-length",adoStream.Size
                        Response.AddHeader "Content-Disposition","attachment; filename=" & MyFilename
                        adoStream.Position = 0
                        Response.BinaryWrite adoStream.Read
                        adoStream.Close
                        Set adoStream = Nothing                  
                  else
                        response.write("File not found, it may be been deleted. Please try another file")
                        response.write("<br>")
                        response.write("Id=" & MyId & ", Tel=" & MyTel & ", File=" & MyFilename & ".")
                  end if
            end if
glad it works ^^
Yeah there is actually a component of BeLight/BeSweet developed by someone else which specifically increases the volume.  It's called "BoostWave CLI"
refund
* paq/refund
All,

Apologies, I totally forgot this was still open.

I'm happy to get a refund if everyone else is, as I solved it pretty much myself.  However I would like to at least say sorry, and give 100 points to both "justchat_1" and "sakuya_su" for leaving this open so long, and for their inital input.

Thanks

ASKER CERTIFIED SOLUTION
Avatar of ee_ai_construct
ee_ai_construct
Flag of United States of America 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