Subject:Finding Silent Points
Posted by: TCarrillo
Date:9/13/2007 12:18:42 AM
I record for long sessions and place markers at specific events dufing the recording. At the end of the recording I have to manually move the markers to the point of where the event actually started not the point at which I thought it was going to be while recording. I have been trying to write a script to take the current position of the marker and backup two seconds then scan forward 4 seconds and look for the quietest point of the selection, then move the marker to where the volume starts to increase. I can't seem to find any examples of finding the quietest point in a selection. Can someone help me? Thank you. |
Subject:RE: Finding Silent Points
Reply by: _TJ
Date:9/13/2007 7:59:39 PM
You can use Statistics to calculate the average RMS value for a range of time, average RMS correlates well to what humans percieve as "loudness". But this only works over a range of time, You can't measure the loudness of a single sample. So I would recommend that you start by using statistics to measure the loadness for 2 seconds before the marker, and then again for 2 seconds after. Then pick the lowest RMS value, and use that to move the marker either 1 second forward or 1 second backward. (so move the the center of the softest half). then get RMS value for 1 second before the new marker position and 1 second after. once again pick the softest, and move the marker 1/2 second forward or backward to the center of the softest area. repeat as many times as you want, 1/2 second, 1/4 second, 1/8 second, etc. Stop when you feel that your markers are accurate enough. I would suspect that 1/16 or 1/32 of a second would be good enough, But you can keep going right down to a search size of 1 sample if you want. RMS values aren't really meaningful down that low, but you will still be quite close to the ideal starting point because by the time RMS values aren't meaningful, your search size has gotten quite small. That gets you to the quietest point. Then you scan forward from there in chunks of 1/10th or 1/20th of a second until the RMS value suddenly jumps. You will need to play with it a bit to come up with a good value for "suddenly jumps". Maybe keep scaning until the RMS value is double what it was at the quiet point. or maybe keep scanning until the value is 50% more than the previous one, etc. or maybe you start looking at the minimum and maximum peak values in the scan range instead of RMS values. There is a statistics sample script called Statistics.cs. It scans the whole file and then prints out the results. Here is some basic code to use statistics for searching. this is a code fragment, not a complete program, it shows one iteration of the search for softness.
tj Message last edited on9/13/2007 8:13:17 PM by_TJ. |
Subject:RE: Finding Silent Points
Reply by: TCarrillo
Date:9/14/2007 4:56:29 PM
SonyTJ, Thank you VERY much for responding so quickly. I tried running the script but got an error accured during execution. Here is the message. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Value does not fall within the expected range. at SoundForge.ISfFileHost.UpdateStatistics(SfAudioSelection asel) at EntryPoint.Begin(IScriptableApp app) at EntryPoint.FromSoundForge(IScriptableApp app) --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at SoundForge.ScriptHost.ScriptManager.Run(Assembly asm, String className, String methodName) at SoundForge.ScriptHost.CodeDomScriptManager.Run(Assembly assy) at SoundForge.ScriptHost.RunScript(String szFile, String szSourceText, EngineType eType, Boolean fCompileOnly, Boolean fDebug) |
Subject:RE: Finding Silent Points
Reply by: _TJ
Date:9/18/2007 12:04:41 PM
So, look at the error report. It's telling you what the problem is. Value does not fall within the expected range. at SoundForge.ISfFileHost.UpdateStatistics(SfAudioSelection asel) So, an out of range value is passed to UpdateStatistics. which means either the start or the length is out of range. most likely it's the start is being set to < 0. but it could also be a negative length, or a start + length > the length of the file. from here I can't tell you which of these is the actual problem. You can try using the DPF() function to print the values of asel.Start and asel.Length to the Script Editor's output window before you call UpdateStatistics tj |
Subject:RE: Finding Silent Points
Reply by: TCarrillo
Date:10/4/2007 10:33:26 PM
SonyTJ, I've tried to get this working and have had no luck. I am not really strong on C#. Any more help would be greatly appreciated. Thank you. |
Subject:RE: Finding Silent Points
Reply by: _TJ
Date:10/6/2007 12:14:25 AM
Sorry, but I can't be any more help unless you tell me what's wrong. or at least tell me what you are doing and what response the machine is giving you. I'm a programmer, not a psychic... ;) tj |
Subject:RE: Finding Silent Points
Reply by: RKPCM
Date:6/25/2009 9:28:03 AM
Hi TJ, I've been reading through your posts and would like to know if you are available to write a script for me? I'd be happy to pay you for your time. There are three pieces of information I'm looking for and this could be acquired from one or three scripts, it doesn't matter to me. 1. Finding the RMS value of a track and outputting it to pipe delimited file with the file name | RMS value. 2. Finding the in and out points of a song based on the volume. Example is a track has silence for the first 7 seconds and then starts at the 7 second mark. We would want to scan a series of tracks (batch) and output the following information to a pipe delimited file: File Name | in point (first place volume in track is above -20 DB) | out point (Last place volume in track is above -20 DB) Example: Bob Marley - Exodus.ogg | 00:07:01 | 03:48:00 3. Finding the beats in the first 10 seconds of a track and the last 10 seconds of a track and exporting that information to a pipe delimited file. For example: Bob Marley - Exodus.ogg | 00:01:00 | 00:01:15 | 00:02:00 etc.. for first 10 seconds and then again for the last 10 seconds | 03:38:00 | 03:38:15 | 03:39:00. The first one is the most important, followed the be the second and the third isn't really as important and will depend on the cost. Thanks for your help and I look forward to hearing back from you. Regards, RK |