float in Python is actually double in C#. You probably want: from System import Single
System.Array.CreateInstance(Single, ...) And so on. From: users-boun...@lists.ironpython.com [mailto:users-boun...@lists.ironpython.com] On Behalf Of Daniel D. Sent: Wednesday, November 04, 2009 12:12 PM To: users@lists.ironpython.com Subject: [IronPython] Reproducing an C# array of floats Hi all, Sorry for the silly question. I'm quite new to ironpython and I've been trying to solve this issue for the last 3 hours. I'm not able to reproduce this code in IronPython. float[] sample = new float[8192/sizeof(float)] I've tried the following but nothing seems to work in my specific case: System.Array.CreateInstance(float, (8192/4)) clr.Reference[System.Array[float]](8192/4) System.Array[float]([(8192/4)]) I'm trying to use the SlimDX to capture the microphone input, and pass it to NumPy to do same FFT stuff. The original C# code is here: http://crsouza.blogspot.com/2009/08/capturing-sound-from-microphone-using.html And here my modified version import clr clr.AddReference('SlimDX') from SlimDX import * from System import * captureDevice = DirectSound.DirectSoundCapture() waveFormat = Multimedia.WaveFormat() waveFormat.FormatTag = Multimedia.WaveFormatTag.IeeeFloat # For Int16, change to Pcm waveFormat.BitsPerSample = 32 # Floats are 32 bits waveFormat.BlockAlignment = (waveFormat.BitsPerSample/8) waveFormat.Channels = 1 waveFormat.SamplesPerSecond = 44100 waveFormat.AverageBytesPerSecond = waveFormat.SamplesPerSecond*waveFormat.BlockAlignment*waveFormat.Channels bufferDescription = DirectSound.CaptureBufferDescription() bufferDescription.BufferBytes = 8192 bufferDescription.Format = waveFormat bufferDescription.WaveMapped = False buffer = DirectSound.CaptureBuffer(captureDevice,bufferDescription) buffer.Start(True) #float[] sample = new float[8192/sizeof(float)]; #sample = Array.CreateInstance(float, (8192/4)) #sample = clr.Reference[Array[float]](8192/4) sample = Array[float]([(8192/4)]) while (True): #print sample print buffer.Read(sample, 0, True); .... which is generating the following error C:\Documents and Settings\Administrator\My Documents>ipy sound_capture_test.py Traceback (most recent call last): File "sound_capture_test.py", line 34, in sound_capture_test.py TypeError: Read() takes at least 2147483647 arguments (3 given) Any help will be very appreciated. Thanks, Daniel ________________________________ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you.<http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010>
_______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com