[chuck-users] running chuck as a process with no terminal?

Spencer Salazar ssalazar at CS.Princeton.EDU
Tue Nov 14 13:28:20 EST 2006


Howdy,

On Nov 14, 2006, at 1:45 PM, altern wrote:

> Spencer Salazar wrote:
>> Hi Enrike,
>>
>> On Nov 13, 2006, at 7:23 PM, altern wrote:
>>
>>> hi
>>>
>>> i am launching chuck from python (i have a python GUI and chuck
>>> works as
>>> sound engine). When I run chuck from python it opens a terminal, I
>>> would
>>> like to hide this. I use python os.spawnv command for this.
>>>
>>> In PD there is a startup flag -nogui that launches pd as a process
>>> with
>>> no console whatsoever, only visible via top or process list.  
>>> Anything
>>> like that in ChucK? i have checked the documentation for the virtual
>>> machine but i could not see anything in this direction.
>>
>> You might try using os.popen; I don't really know Python but looking
>> through the docs that function seems geared for use with console
>> apps, so it might work better for your purposes.
>>
>> ChucK doesn't have a -nogui flag, because it doesn't really have
>> control over its gui; it just gets the default command line gui on
>> win32 because its compiled as a console app.
>
> but this does not work as i need. Python and ChucK need to run
> concurrently. Maybe I am wrong (there are a lot of them and the  
> docs are
> not very descriptive for non the non savvy like me) but I found  
> that the
> only way to do this was with os.spawn family of functions passing
> os.P_NOWAIT as mode argument. This triggers the process and does not
> wait for it to return or exit. On the contrary popen seems to trigger
> the process and wait for it to finish, i just did one more test.
>
> So if i would compile ChucK not to be a console app then it could  
> run as
> a process? how difficult is that? I never compiled before under XP, i
> dont like the idea very much but maybe it is worth the pain ...

It would be pretty difficult to do that, I imagine.  I suspect you  
would have to write a WinMain function that just calls chuck's main,  
and then lose a few libraries... thats how I would go about it, but  
Im not totally certain, its not really a process that I am familiar  
with.

You might have better luck getting help from the python/Windows  
community on how to execute console programs without getting a  
terminal (as Joerg has demonstrated that this is at least possible  
with chuck in its current form).  Don't get me wrong, we're not  
trying to get rid of you, but I suspect that running any console  
program from python in this way will pop up a terminal, so it could  
be something that other python users have found answers for.

Also, it doesn't make sense to me that popen would wait for the  
process to finish, as it is designed for executing other processes in  
tandem with the parent process.  I can see from the python docs that  
the child process's exit status is returned from the close() call to  
the file object that popen returns, so that would suggest to me that  
it doesn't wait for the process to finish.  This is the behavior I  
observed in my primitive testing within python on my box, at least...

>>> Another important issue i am having is that as soon as the chuck
>>> terminal loses the focus the sound stops. So when I select the  
>>> python
>>> window the sound stops. Is there any way to avoid this?
>>
>> Yikes, I have come across this as well.  Does this happen when
>> switching to any window, or just your python window?
>
> aha! yes i does it only when selecting the python window. Any ideas  
> why?

The same effect happens to me when I run chuck and then switch to  
Finale.  Switching out of Finale will cause chuck to continue  
processing.  I could be completely off track with this idea, but is  
there any way to easily disable audio in pygame?  pygame's sound  
driver could be "blocking out" chuck's sound driver.

hope this helps,
spencer

>> Past recommended solutions have been to increase the audio buffer
>> size with --bufsize1024 or --bufsize2048, but on my XP SP2 system
>> those don't even produce audio... so I can't vouch for those.
>
> I see, i will try to experiment with different values. The funny thing
> about this is that it does not do it when running the python  
> application
> from .py file. I mean it only does this when I 'compile' the app with
> py2app as exe. Similar things happens with opening the terminal, when
> python opens a terminal (always when the file run is a .py) then ChucK
> uses the Python terminal to print the errors and messages. This is
> *really* cool as it helps a *massively* with dealing with debugging  
> both
> programs at the same time. This is one of the reasons why I decided to
> try ChucK instead of PD. But when python does not open its terminal
> (when the file is .pyw or is an .exe) then ChucK opens the terminal :(
>
>>> I am working on xp at the moment, so i havent tested if this
>>> happens as
>>> well on linux or osx.
>>
>> I would expect you to have much better success on either of those
>> platforms...
>>
>>> I have very limited access to internet for a few days so i cannot
>>> search
>>> on the mailing list archive or the forum about this issue. Sorry.
>>
>> No worries!  Hope this helps...
>>
>> spencer
>>
>>> thanks
>>>
>>> enrike
>>>
>>>
>>>
>>> _______________________________________________
>>> chuck-users mailing list
>>> chuck-users at lists.cs.princeton.edu
>>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>
>> _______________________________________________
>> chuck-users mailing list
>> chuck-users at lists.cs.princeton.edu
>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>
>
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users



More information about the chuck-users mailing list