Subject:MixAudio parameters
Posted by: korigan
Date:9/22/2005 10:07:32 AM
Hello, MixAudio( SfAudioSelection, 1.0,-0.5, FileMusic, sfAudioSelection) ); I'm using the MixAudio function, but I can't find what is the explanation of parameters number 2 and 3. Online Help doesn't display informations about them since help can't find pages for them. I think it must be the dB, but it looks like I don't have the same results when using the same values in the dialogbox or with the function call Thanks for help |
Subject:RE: MixAudio parameters
Reply by: jetdv
Date:9/22/2005 1:19:41 PM
MixAudio(SoundForge.SfAudioSelection aselDst, double dGainDst, double dGainSrc, SoundForge.ISfFileHost fileSrc, SoundForge.SfAudioSelection aselSrc); |
Subject:RE: MixAudio parameters
Reply by: korigan
Date:9/23/2005 2:09:33 AM
Hello, Thank you but I have already found this definition, but when I click on dGainDst or dGainSrc the help can not find HTML pages. So I have no explanation for these 2 parameters. My problem is when I want to keep data in the same state and I use 0.0 there no more sound. When I use parameters it seems they are not the same as the ones I use in the dialog box for mixing (db) Thanks for help |
Subject:RE: MixAudio parameters
Reply by: _TJ
Date:9/23/2005 11:43:48 AM
They are gain values, but not in dB, they are multipliers. Essentially these are the numbers you would get AFTER you convert from dB into an value that can be used in the actual DSP code. I believe that they are referred to as Ratio type values in places in the code. A value of 1.0 is equivalent to 0 dB. (i.e. no change) A value of 0.0 is equivalent to -Inf dB And there you may see the problem. -Inf is actually not expressible in a double, which makes working with dB values a bit awkward down in code like this. As a general rule, there is no place in Script where methods take dB values as arguments. If you want to work with dB values, just use the helper functions to convert them to multipliers just before you call MixAudio or other functions that take gains. public class SfHelpers { public double RatioTodB(double dRatio, double dBMin); public double dBToRatio(double dB, double dBMin); ... } Note that SfHelpers.RatioTodB(double dRatio, double dBMin ) needs TWO doubles as arguments, so that it can know what double value would represent -Inf. There is also a simplified version of each of these methods that assumes that dBMin is -96, which is plenty of resolution when working with data that will end up being saved out as 16 bit. using System; using SoundForge; public class EntryPoint { public void Begin(IScriptableApp app) { DPF("2.0 is {0} dB", SfHelpers.RatioTodB(2.0)); DPF("1.0 is {0} dB", SfHelpers.RatioTodB(1.0)); DPF("0.5 is {0} dB", SfHelpers.RatioTodB(0.5)); DPF("0.0 is {0} dB", SfHelpers.RatioTodB(0.0)); DPF("-600 dB is {0}", SfHelpers.dBToRatio(-600.0)); DPF("-100 dB is {0}", SfHelpers.dBToRatio(-100.0)); DPF("-96 dB is {0}", SfHelpers.dBToRatio(-96.0)); DPF("-6 dB is {0}", SfHelpers.dBToRatio(-6.0)); DPF("0 dB is {0}", SfHelpers.dBToRatio(0.0)); DPF("2.0 dB is {0}", SfHelpers.dBToRatio(2.0)); DPF("100.0 dB is {0}", SfHelpers.dBToRatio(100.0)); } public void FromSoundForge(IScriptableApp app) { ForgeApp = app; //execution begins here app.SetStatusText(String.Format("Script '{0}' is running.", Script.Name)); Begin(app); app.SetStatusText(String.Format("Script '{0}' is done.", Script.Name)); } public static IScriptableApp ForgeApp = null; public static void DPF(string sz) { ForgeApp.OutputText(sz); } public static void DPF(string fmt, object o) { ForgeApp.OutputText(String.Format(fmt,o)); } } //EntryPoint tj Message last edited on9/23/2005 12:10:02 PM by_TJ. |
Subject:RE: MixAudio parameters
Reply by: stikyy
Date:12/8/2005 2:20:39 AM
How would i just increase the volume on a audio selection? I am using... (partial code) Dim file As ISfFileHost = app.CurrentFile Dim outRange As SfAudioSelection = New SfAudioSelection(file) Dim gain as Double = SfHelpers.dBToRatio(-15) file.MixAudio(outRange, 1, gain, file, outRange) But i am not sure if its working right. |
Subject:RE: MixAudio parameters
Reply by: _TJ
Date:12/8/2005 11:53:51 AM
Gain values > 1.0 will increase the volume, gain Values < 1.0 will decrease. Use eactly 1.0 to mix without changing the volume. When using SfHelpers.dBToRatio(), negative values will decrease the volume, positive values will increase and 0 will result in no change in volume. tj |