Sunday, January 17, 2010

Communicate with aliens on IronPython (ending)

Previously, we are talking with aliens in C#, Nemerle, Boo and F#. Now let's try to do the same on IronPython.
See code below.

from System import *
from System.Collections.Generic import *
from System.Text import *
from Alvas.Audio import *

def rex_Open(sender, e):
    _play.OpenPlayer(_pcmFormat)
    _play.StartPlay()

def rex_Close(sender, e):
    _play.ClosePlayer()

def rex_Data(sender, e):
    data = AudioCompressionManager.Reverse(_pcmFormat, e.Data)
    _play.AddData(data)

_play = PlayerEx(True)
_pcmFormat = AudioCompressionManager.GetPcmFormat(
11644100)
_rex = RecorderEx(True)
_rex.Data += rex_Data
_rex.Open += rex_Open
_rex.Close += rex_Close
_rex.Format = _pcmFormat
_rex.StartRecord()
Console.WriteLine(
"Please press enter to exit!")
Console.ReadLine()
_rex.StopRecord()
    


Enjoy:)
The source code and precompiled examples are here. (AudioConsPy.zip)

kick it on DotNetKicks.com

Shout it

No comments:

Post a Comment