sh0dan // VoxPod

Thursday, January 11, 2007

SoundOut plugin for AviSynth

I have spent some time on my new project, a sound output plugin for AviSynth. It was actually one of many projects, but I wanted to do something new, so a GUI-based AviSynth filter seemed like a good challenge.

I had recently touched "traditional" windows GUI, when developing for Windows CE, but it has been years since I last had done some real GUI work (which honestly was mostly copy+adapt+paste). And since I had recently been frustrated with the effort required to export sound from AviSynth, I had myself a project. Enter SoundOut:


Yes - there are still some grayed out boxes, so I obviously haven't finished, but right now I struggling with Commandline Output using pipes and slowly implementing general parameter and preset handling.

Even though the Resource Editor has been disabled in the Visual Studio 2005 Express, I choose to go the "oldfashioned" way, and use Common Controls. I had tried using CLR Windows Forms for a simple GUI for the TCPDeliver server, but I didn't manage to integrate it into the current code, since it required the project to be compiled with CLR support.

After some frustration (since I refuse to go back to VS 6) I did however find a very nice free resource editor called resED. It works very well, if you create your resources from scratch - it does seem to have small problems importing VC6 resources. But with that in mind, I haven't had any additional issues with it. I did however find out how hard it actually is to find coding documentation on on Common Controls on MSDN - you have to dig very deep at times.



It has been quite nice to work with prebuilt libraries. The API's are usually very different. None of them are perfect, but they usually work quite well within their limitations. So far the only problem besides the usual linker strangeness has been time. Building GUIs are extremely time-consuming - I had almost forgotten how it was - but it just takes so much time to get everything tweaked right the way you want it. I love the control you have in C++, but trivial tasks like adding a checkbutton for an output option simply takes a long time. Right now the workflow is:
  • Add GUI element in the resource editor.
  • Setting the internal parameter to default value on output module creation.
  • (Apply presets / script value overrides - This is thankfully generic code)
  • Setting the parameters to the GUI.
  • Waiting for user inputs.
  • Transfer user GUI values to internal parameter storage.
  • (Save internal parameters - again generic code)
  • Apply the internal parameters to the output module.
This is (obviously) of the things I'm considering adding more generic code for. If I could set up simple relations between GUI elements and internal parameters for checkboxes, sliders, etc. a lot of code would probably be a lot simpler.

Ok - seems like we are getting a bit to technical here. I could wrote for hours about the threading and performance stuff, but I'll stop here... Either way, I see this as a good personal development project - and I also hope a few more people will use this than TCPDeliver, or AviSynth 2.6 for that matter! ;)



The future for this project holds:
  • Storing and loading presets.
  • A framework for attaching buttons to parameters internally.
  • Read settings from script.
  • Implement missing compression types.
  • Test & Documentation.
  • Sound Input filters? We already have the libraries - most of them have some input modes.

But there are other possible projects (in no specific order) I hope to get some time for:
  • Putting more time into finishing up AviSynth 2.6.
  • Writing a kernel blur, using the AviSynth resizer.
  • Yet another GUI for AviSynth. ;)
  • Beginning a new project on a GPU-based RAW photo converter from scratch.
  • Getting more work done on a text-indexing project I've been working on.
... But as always time and energy is the limiting factor. Right now the NFL Playoffs are taking away my weekend evenings. It also seems like there is a Symbian port of my work project coming up - so odds are against much more than finishing up the projects.

6 Comments:

  • pretty sweet..

    By Blogger Unknown, at 11:04 pm  

  • Great work!

    I got an issue, god knows what the cause is, because it works on one PC and not on another...

    well... as soon as its finished exporting the audio, i've specified for it to autoclose etc., but as soon as it autocloses, it then crashes x264.exe build 671. This doesnt happen on another machine, the same directshow filters are in the chain and same version of Avisynth etc etc. The only difference is that it crashes on WinXP SP2 and not on my W2003 SP2.

    the ironic thing is that the audio comes out properly, and there is a physical file just sitting there, perfect, but it seems as if soundout doesnt let go of some memory or something or other... could you double check to make certain that everything is gracesfully released? or at least try to catch the error and write it out to a log file/event log or something and just continue to close gracefully?

    Many thanks for this beauty!

    By Anonymous Anonymous, at 8:40 pm  

  • Is there a way to run SoundOut "standalone" in batch mode?
    I need a very simple program that does nothing but load an .avs file to run SoundOut on an .avi
    The program needs to be simple and trivial, because it's going to run emulated (WINE on Linux), not on native Win32 platform.
    It has to be non-gui because it has to run in a loop, to process many .avi files.

    By Anonymous Anonymous, at 6:42 pm  

  • I would like to ask for help my friend. I am trying to re-encode (or
    whatever its called) a mac file (.caf) for PC (while using winxp)(.mp3, wav, doesn't
    matter), i have QT PRO. It says
    "version 7.6 (472)
    Quicktime version 7.6 (1292)"

    When i open .caf file it says
    " To play this file you need additional software. It may be available from
    Quick Time Components'
    and when i click next it sends me here

    http://www.apple.com/quicktime/resources/components.html?os=Windows&ctype=61646563&csubtype=73616331
    but on this site none of these things have to do anything with sound

    The files i'm trying to convert come from Garagebad tutorials, artist
    lessons, i was able to open older tutorials from apple garageband (like few months
    ago) by qt pro and then play them and export them.


    When i drag files to audacity now i can see that there is voice inside (i
    saw these ymmm mountains,who knows hows this called :)
    [url=http://img162.imageshack.us/img162/2166/audacitysoundcostam.png][color=blue]sound diagram
    something :P[/color][/url]) but when i click play its just 1 second of cracks and
    it stops. Tried also in adobe audition (i renamed to .aiff, m4a, mp4) and
    nothing. I also tried dbpoweramp with aiff extention and change caf to aiff but
    it says 'wrong beginning' or something like that. When i click in QT -
    window-> show properties of movie, it says under the audio format 'sac1'

    This is older file i was able to use with QT - (10mb)
    http://www.mediafire.com/?kjjenejz3zi
    this is the one of many i am not able to - (30mb)
    http://www.mediafire.com/?3owritijdoz

    Is there any way i can now change file to mp3 or wav? Maybe some plugin to
    audacity? (i was unable to find it) Last time i spent 2 weeks figuring out
    what to do, and now the previous method doesn't work? Did they make new
    protection system?

    Thank you for your time.

    QM

    By Blogger 10, at 10:00 am  

  • ow, please contact me at real_untouchable [(att)] o2.pl
    thank you so much

    By Blogger 10, at 10:01 am  

  • great....
    I work with soundout to calculate how much increase the sound of my avi's .Its just a little problem when a peak is during a short time. If I could see the duration of the peaks ,it will be fantastic.

    thanks

    By Anonymous gmanvu, at 1:13 pm  

Post a Comment

<< Home