Jump to content

AutoIt Data Conversations?


Recommended Posts

enigmatic thread title, sorry. i'm a mega-lurker when it comes to here, though autoit is my favorite language. tend to consult help file, but when that lets me down or just doesn't help at all, i end up here.

so, on to it.

*wall-o-text warning*

I'm writing a "soundscape" type program using a lot of nature sound effects. What it does (at least the present iteration) is plays back a number of thunder effects randomly, over rain and wind effects. There's about 4 separate channels of sound (rain, wind, and two thunder channels for near and distant effect), each requiring its own autoit-program in the background to play. All is managed by a "main" program that provides play/pause control (kill or run the subprograms) and also theme toggling (i have lighter rain effects so it can toggle to that instead of the big storm).

Well now I have a lot more sounds. And I can't really break them all up into separate programs (I use FileInstall to temp folders for the sounds, mp3 format, one program per "theme" set). So I want to make one single program to handle any combination of the effect channels, with a variable number of subprograms to play those channels. I would like to try and keep the number of background processes to a minimum, since I'm guessing it becomes a serious memory hog after a while (multiple SoundPlay, plus random being calculated each time, and the main program constantly checking a tray menu). In the current iteration, I can have the two rain effects (heavy and light) in one program, with a command line parameter telling it which to play when the main program runs it. But I'd like to be able to have the various effect sets be able to start and stop without the need to close and restart subprograms (more fluid that way). So, here is what I'm looking for. I'll use the stormy theme to example since I've done that for each of my iterations.

Main manager program spawns off four subprograms, Rain, Wind, Distant Thunder, Near Thunder. Wind contains effects for non-rainy wind, like just a calm wind or something, so Wind is used in multiple themes. Main manager sends a command of some sort to Rain to use the heavy effect. Rain receives it and starts looping the heavy rain. Same happens for Wind, it gets a command from the manager to play heavy wind loops. The two thunders don't get commands since they can be used anytime (like distant thunder over a calm scene, giving the effect of an approaching storm). Everything loops, all is good. Then the theme changes, say to a calm theme. Main program just kills off the Rain and Thunder programs since they aren't needed, spawns off the subprograms for the Calm theme, and then sends a command to Wind to use a calm effect instead of the heavy one. Wind changes, all is good.

I'd like to be able to go beyond preset themes and have a bunch of checkboxes for all the possible channels, obviously using radio buttons for those subprograms that contain multiple themed effects (like Wind). That way the end-user can construct their own theme, and the main manager just runs/kills/commands the subprograms accordingly.

So is this even feasible? To have this kind of communication between autoits?

Also, is there a better way to do this in the first place? Multiple sound channels that loop in different times, without multiple background processes? Is it (easily) possible in any other language? AutoIt's my favorite because it's so easy to do stuff like this, everything else becomes a serious headache. Is something like this not possible to do with just one AutoIt program?

Link to comment
Share on other sites

I have accomplished communication between two AutoIt scripts by using the hidden AutoIt window.

For every instant of AutoIt running there is a hidden window, you can set the title of this window using AutoItWinSetTitle.

This window consists of a readonly edit control (Edit1).

The window, when shown, looks like this: Posted Image

As you can see, very plain and simple.

Anyway, to the point of my rambling. Using that edit control I have passed parameters from one script to another. So far I've only done very simple things.

Here's a simple example. Try running this script once, you won't see anything, then run it again, and the window should appear. I've used similar code several times for programs with windows you can completely hide, or even for programs that you only want running once, then when the user tries to run it again, it just puts the focus on the already running program.

$sAutoItTitle = 'MyTestProgram-AutoItWinTitle'
If WinExists($sAutoItTitle) Then
     ControlSetText($sAutoItTitle, '', 'Edit1', 'ShowWindow')
     Exit
EndIf
AutoItWinSetTitle($sAutoItTitle)

GUICreate('Test', 200, 200)

While 1
    $sAutoItWinCmd = ControlGetText($sAutoItTitle, '', 'Edit1')
    If $sAutoItWinCmd <> '' Then
        If $sAutoItWinCmd = 'ShowWindow' Then
            GUISetState(@SW_SHOW)
        EndIf
        ControlSetText($sAutoItTitle, '', 'Edit1', '')
    EndIf

    $gm = GUIGetMsg()
    Switch $gm
        Case -3
            ExitLoop
    EndSwitch
WEnd

Like I said, a pretty simple example, nothing in the vein of what you need, but it's how I've been communicating between scripts. I'm sure you could figure something out using the same concepts.

Link to comment
Share on other sites

Okay, I whipped up some stuff. Don't know if this will help or confuse, but I'm hoping it will help.

So I have three files here.

soundscapeInc.au3 - http://www.therks.com/autoit/soundscapeex/soundscapeinc.au3

soundscapeParent.au3 - http://www.therks.com/autoit/soundscapeex/...scapeparent.au3

soundscapeChild.au3 - http://www.therks.com/autoit/soundscapeex/...dscapechild.au3

Grab all three, and run the parent script first (feel free to check the code first if you're worried i'm a mad hacker :)). Then run one or more of the child script, and play with the buttons. Again not a super advanced example by any means, but hopefully it will give you some more ideas.

Link to comment
Share on other sites

Well, the present iteration works perfectly. MP3 sounds (so glad i found out you can SoundPlay mp3s), there's a few command line params available too. The finer details on those are in the source, but I also put the switches in the Comments part on the properties box.

Also have made thread: http://www.autoitscript.com/forum/index.php?showtopic=52890

the first one was pretty bad, but wasn't totally horrible (loooow quality stuff). second iteration is pretty good, but not as much selection or fidelity on the thunder, and it's wav files so it's really big. hopefully using the idea from here i'll be able to make the fourth iteration even better.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...