Solved

Read WAV, Increase Volume, Write WAV

Posted on 2006-06-30
14
940 Views
Last Modified: 2010-04-28
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

0
Comment
Question by:DukeLito
  • 4
  • 4
  • 3
  • +1
14 Comments
 
LVL 9

Expert Comment

by:justchat_1
ID: 17021573
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17021579
^ Thats a possibility, Im not positive ^
0
 
LVL 10

Expert Comment

by:sakuya_su
ID: 17025007
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
0
 

Author Comment

by:DukeLito
ID: 17029616
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
0
 
LVL 10

Expert Comment

by:sakuya_su
ID: 17030539
u neeed to read about security issues involved with asp shelling an exe
0
 

Author Comment

by:DukeLito
ID: 17037568

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
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 10

Expert Comment

by:sakuya_su
ID: 17039954
glad it works ^^
0
 

Author Comment

by:DukeLito
ID: 17041079
Yeah there is actually a component of BeLight/BeSweet developed by someone else which specifically increases the volume.  It's called "BoostWave CLI"
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17291969
refund
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17291977
* paq/refund
0
 

Author Comment

by:DukeLito
ID: 17294592
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

0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 17356215
PAQ / Refund
ee ai construct, community support moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

746 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

13 Experts available now in Live!

Get 1:1 Help Now