Subject:Append file and match contents
Posted by: gpmanbu
Date:8/11/2010 8:37:32 AM
Hi! I am new to this forum and to the scripting feature. Any help from anyone would be appreciated. Scenario: I have 2 wav files. The 2nd file has x seconds at the beginning that was copied from the end of the 1st file. I wish to merge (append the 2 files) seamlessly. To make sure that there is no overlap I would like to be able to start close to the beginning of the 2nd file and find the exact match in the end of the 1st file and then append the 2nd file seamlessly at that point (ie with no overlap, no duplication). Is this possible? Help Appreciated. |
Subject:RE: Append file and match contents
Reply by: roblesinge
Date:8/11/2010 9:11:49 AM
Let me see if I understand... Wave file 2 has a known number of seconds of audio from wave file 1 at the beginning of the file. You want to overwrite that completely with wave file 1, so that wave file 1 runs right into wave file 2? This might be possible if you know exactly where in file 2 (position in seconds) that the overwrite needs to happen. Your scenario is kind of unclear, but I think I understand. If you don't know the specific position (you called it 'x'), you're going to have some trouble. --Rob. |
Subject:RE: Append file and match contents
Reply by: gpmanbu
Date:8/12/2010 6:54:20 AM
Thanks for the response. I know how to do this in SoundForge itself but in a script it would be faster (Seeing I might have to do this 600 times manually). I was hoping I could for eg start two seconds in to the beginning of file 2 and scan the end of file 1 comparing bit by bit for an exact match. Obviously, looking for eg 4 seconds of matching bits. Is there a way to do this? Is there a way to compare bits and bytes. Thanks |
Subject:RE: Append file and match contents
Reply by: roblesinge
Date:8/12/2010 7:21:55 AM
I was just trying to understand what you wanted the script to do. To my limited knowledge, this sounds a bit too complicated for a script to handle. You'd have to compare at the sample level--which might be possible--although I'm not sure how you would load a sample as an object for comparison. Perhaps someone else can clear that part up. For my money though, 600 manual edits isn't that big of a deal (of course, I do thousands per day, so I might be biased). If you factor in the time to write/test/debug the script, and then randomly check a few files (assuming you trust the SF and the script) you could probably have already done the edits manually. Believe me, I'm the first to try and automate any process, but this one seems too complicated to attempt, if even possible. I'm a relative scripting newb though. Perhaps some of the more experienced programmers have some ideas for you. If you wanted to just do the overwrite based on a specified time in the file. That is completely possible, and a relatively simple script to write. But sample comparison is where the complication starts. --Rob. |
Subject:RE: Append file and match contents
Reply by: ExSonyTJ
Date:8/12/2010 11:20:54 AM
The ISfFileHost object has a ReadSamples method that you can use to read the audio data into an array. So you could do a sample by sample comparison of the two files in order to find the place where they differ. There's an example of how to call this method in the script called GetSamplesTest.cs |