Monday, December 28, 2009

Communicate with aliens on Boo (continued)

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

namespace AudioConsBoo

 

import System

import Alvas.Audio

 

class Program:

 

    static def Main():

        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()

 

    static rex = RecorderEx(true)

 

    static play = PlayerEx(true)

 

    static pcmFormat as IntPtr = AudioCompressionManager.GetPcmFormat(1, 16, 44100)

 

    static def rex_Open(sender as object, e as EventArgs):

        play.OpenPlayer(pcmFormat)

        play.StartPlay()

 

    static def rex_Close(sender as object, e as EventArgs):

        play.ClosePlayer()

 

    static def rex_Data(sender as object, e as DataEventArgs):

        data as (byte) = AudioCompressionManager.Reverse(pcmFormat, e.Data)

        play.AddData(data)

 

Program.Main()


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

kick it on DotNetKicks.com

Shout it

No comments:

Post a Comment