[IronPython] IronPython 2.6 CodePlex Source Update

2009-11-04 Thread merllab
This is an automated email letting you know that sources 
have recently been pushed out.  You can download these newer 
sources directly from 
http://ironpython.codeplex.com/SourceControl/changeset/view/61019.

ADDED SOURCES

$/IronPython/IronPython_Main/Src/Runtime/Microsoft.Scripting.Core/index.htm
$/IronPython/IronPython_Main/Src/Tests/encoded_files/cp1019.py
$/IronPython/IronPython_Main/Src/Tests/silverlight_sanity/index.html

DELETED SOURCES
$/IronPython/IronPython_Main/Src/Tests/test_interpret_sanity.py

MODIFIED SOURCES

$/IronPython/IronPython_Main/Src/Runtime/Microsoft.Scripting.Core/index.htm
$/IronPython/IronPython_Main/Src/Tests/encoded_files/cp1019.py
$/IronPython/IronPython_Main/Src/Tests/interop/net/type/test_clrtype.py

$/IronPython/IronPython_Main/Src/Tests/interop/net/property/test_indexervb.py
$/IronPython/IronPython_Main/Src/IronPython/Lib/iptest/assert_util.py

$/IronPython/IronPython_Main/Src/Tests/ClrAssembly/Src/indexerdefinitionsvb.vb
$/IronPython/IronPython_Main/Src/Tests/silverlight_sanity/index.html
$/IronPython/IronPython_Main/Src/Tests/Modes/ConsoleFlags.ps1
$/IronPython/IronPython_Main/Src/Tests/test_gc.py
$/IronPython/IronPython_Main/Src/Tests/test_exceptions.py
$/IronPython/IronPython_Main/Src/Tests/test_dllsite.py
$/IronPython/IronPython_Main/Src/Tests/test_dict.py
$/IronPython/IronPython_Main/Src/Tests/test_codecs.py
$/IronPython/IronPython_Main/Src/Tests/test_cliclass.py
$/IronPython/IronPython_Main/Src/Tests/test_ipye.py
$/IronPython/IronPython_Main/Src/Tests/test_inheritance.py
$/IronPython/IronPython_Main/Src/Tests/test_help.py
$/IronPython/IronPython_Main/Src/Tests/test_memory.py
$/IronPython/IronPython_Main/Src/Tests/test_methoddispatch.py

CHECKIN COMMENTS

Changeset Id: 1248149
Date: 11/2/2009 3:47:58 PM

(dfugate) - CP1019 (test_codecs.py) - added regression.  Not fixed
- test_dllsite.py.  Added a regression for a fixed bug
- test_exceptions.py.  Added a regression for one fixed bug...opened another in 
the process
- CP8202 (test_gc.py) - not fixed
- CP4190 (test_help.py) - added regression.  Fixed
- CP6703 (test_ipye.py) - added regression.  Fixed
- CP3740 (test_indexervb.py) - added regression.  Not fixed (or won't fix?)
- ConsoleFlags.ps1 - added regression.  Fixed


(Shelveset: CP78;REDMOND\dfugate | SNAP CheckinId: 9737)



___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] Adding imports?

2009-11-04 Thread Slide
Is it possible to add imports to a script without just adding text to the
source code before compilation?

Maybe something on the script scope or something?

Thanks

-- 
slide-o-blog
http://slide-o-blog.blogspot.com/
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Adding imports?

2009-11-04 Thread Dino Viehland
You can do:

scope.SetVariable(name, engine.ImportModule(module_name));

Where ImportModule is an extension method defined in IronPython.Hosting.Python.

From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Slide
Sent: Wednesday, November 04, 2009 9:05 AM
To: Discussion of IronPython
Subject: [IronPython] Adding imports?

Is it possible to add imports to a script without just adding text to the 
source code before compilation?

Maybe something on the script scope or something?

Thanks

--
slide-o-blog
http://slide-o-blog.blogspot.com/
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Adding imports?

2009-11-04 Thread Slide
That is perfect! Thanks!

On Wed, Nov 4, 2009 at 10:08 AM, Dino Viehland di...@microsoft.com wrote:

  You can do:



 scope.SetVariable(“name”, engine.ImportModule(“module_name”));



 Where ImportModule is an extension method defined in
 IronPython.Hosting.Python.



 *From:* users-boun...@lists.ironpython.com [mailto:
 users-boun...@lists.ironpython.com] *On Behalf Of *Slide
 *Sent:* Wednesday, November 04, 2009 9:05 AM
 *To:* Discussion of IronPython
 *Subject:* [IronPython] Adding imports?



 Is it possible to add imports to a script without just adding text to the
 source code before compilation?

 Maybe something on the script scope or something?

 Thanks

 --
 slide-o-blog
 http://slide-o-blog.blogspot.com/

 ___
 Users mailing list
 Users@lists.ironpython.com
 http://lists.ironpython.com/listinfo.cgi/users-ironpython.com




-- 
slide-o-blog
http://slide-o-blog.blogspot.com/
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Adding imports?

2009-11-04 Thread Dave Purrington
You can load assemblies as well. For example, the hosting assembly:

Assembly mainAssembly = Assembly.GetExecutingAssembly();
string rootDir =
Directory.GetParent(mainAssembly.Location).FullName;

_engine.Runtime.LoadAssembly(mainAssembly);


On Wed, Nov 4, 2009 at 12:11 PM, Slide slide.o@gmail.com wrote:

 That is perfect! Thanks!

 On Wed, Nov 4, 2009 at 10:08 AM, Dino Viehland di...@microsoft.comwrote:

  You can do:



 scope.SetVariable(“name”, engine.ImportModule(“module_name”));



 Where ImportModule is an extension method defined in
 IronPython.Hosting.Python.



 *From:* users-boun...@lists.ironpython.com [mailto:
 users-boun...@lists.ironpython.com] *On Behalf Of *Slide
 *Sent:* Wednesday, November 04, 2009 9:05 AM
 *To:* Discussion of IronPython
 *Subject:* [IronPython] Adding imports?



 Is it possible to add imports to a script without just adding text to the
 source code before compilation?

 Maybe something on the script scope or something?

 Thanks

 --
 slide-o-blog
 http://slide-o-blog.blogspot.com/

 ___
 Users mailing list
 Users@lists.ironpython.com
 http://lists.ironpython.com/listinfo.cgi/users-ironpython.com




 --
 slide-o-blog
 http://slide-o-blog.blogspot.com/

 ___
 Users mailing list
 Users@lists.ironpython.com
 http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Safe execution of python scripts on my .net application

2009-11-04 Thread Shri Borde
http://www.dev102.com/2008/03/22/3-ways-to-run-nunit-from-visual-studio/ has 
some info about test projects and appbase problems.

You can also use fuslogvw 
(http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx) to see why 
Microsoft.Scripting.dll is failing to load.

From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Dino Viehland
Sent: Tuesday, November 03, 2009 1:52 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Safe execution of python scripts on my .net 
application

Test projects are weird and somehow you don't end up inheriting the application 
base.  This seems to work though:

AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
AppDomain aSandboxedDomain = AppDomain.CreateDomain(Sandboxed 
Domain, null, setup);
ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);
ScriptSource source = engine.CreateScriptSourceFromString(2+2);
ScriptScope scope = engine.CreateScope();
Console.WriteLine(source.Execute(scope));

From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Nicolás Buttarelli
Sent: Tuesday, November 03, 2009 1:30 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Safe execution of python scripts on my .net 
application

I have create a new Test Project and an Unit Test class in order to test the 
following code inside:

AppDomain aSandboxedDomain = AppDomain.CreateDomain(Sandboxed Domain);
ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);
ScriptSource source = engine.CreateScriptSourceFromString(pythonScript);
ScriptScope scope = engine.CreateScope();
source.Execute(scope);


I have add the references:

- IronPython
- Microsoft.Scripting
- Microsoft.ScriptingCore

But it still not working and throwing the same 
System.Runtime.Serialization.SerializationException: Type is not resolved for 
member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting.

Any ideas?


2009/11/3 Nicolás Buttarelli 
nbuttare...@gmail.commailto:nbuttare...@gmail.com
Thanks Shri, I will try.

In addition, I found this open issue: 
http://dlr.codeplex.com/WorkItem/View.aspx?WorkItemId=2816. I think that it is 
related.

On Tue, Nov 3, 2009 at 9:29 PM, Shri Borde 
shri.bo...@microsoft.commailto:shri.bo...@microsoft.com wrote:
I think this happens if the new appdomain cannot load the required assembly. By 
default, the new appdomain should inherit its BaseDirectory property from the 
creating domain and should be able to load Microsoft.Scripting.dll. Is your exe 
and all the dlls in the same folder? If not, can you try to put all assemblies 
in the same folder (or in the GAC) to see if it works? If that works, you can 
then figure out how to configure the new appdomain such that it can load 
Microsoft.Scripting.dll. There may be some setting in AppDomainSetup, or you 
could hook the AssemblyResolve event...

From: 
users-boun...@lists.ironpython.commailto:users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.commailto:users-boun...@lists.ironpython.com]
 On Behalf Of Nicolás Buttarelli
Sent: Tuesday, November 03, 2009 12:08 PM

To: Discussion of IronPython
Subject: Re: [IronPython] Safe execution of python scripts on my .net 
application

Hi again, thanks for your clear response.

I was trying to do what you proposed but it is not working. I am receiving an 
exception:

Test method 
CadworX3WCFRestTest.IronPython.SafeScriptExecutionTest.writingAFileTest threw 
exception:  System.Runtime.Serialization.SerializationException: Type is not 
resolved for member 
'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, 
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'..
I tried to find a solution but I couldn't. This is the minimal code that I am 
running to get this exception (I have removed all the security stuff but 
apparently that does not resolve the problem):

AppDomain aSandboxedDomain = AppDomain.CreateDomain(Sandboxed Domain);

ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);
ScriptSource source = engine.CreateScriptSourceFromString(pythonScript);
SriptScope scope = engine.CreateScope();
source.Execute(scope);

The exception is thronged in this line:
ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);


Do you have any idea which could be the problem?

Thanks again,
Nicolas

On Mon, Nov 2, 2009 at 10:25 PM, Dino Viehland 
di...@microsoft.commailto:di...@microsoft.com wrote:
Assuming the app domain is setup properly then there's no way for the Python 
code to elevate permissions (modulo CLR security bugs which are few and far 
between).  This is because IronPython its self is 100% security transparent and 
does not affect any security decisions or assert any form of trust - so it's 
all up to the CLR to limit permissions.  So for example while you can access 

[IronPython] IronPython 2.6 CodePlex Source Update

2009-11-04 Thread merllab
This is an automated email letting you know that sources 
have recently been pushed out.  You can download these newer 
sources directly from 
http://ironpython.codeplex.com/SourceControl/changeset/view/61024.

DELETED SOURCES
$/IronPython/IronPython_2_6/Src/Tests/compat/sbs_library.dll

MODIFIED SOURCES
$/IronPython/IronPython_2_6/Src/Tests/compat/sbs_func_args.py

CHECKIN COMMENTS

Changeset Id: 1250429
Date: 11/3/2009 12:39:57 PM

(dfugate) Migrated sbs_library.dll change from the Main branch over to IP_26.


(Shelveset: SBS_LIBRARY_IP26;REDMOND\dfugate | SNAP CheckinId: 9735)



___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] Reproducing an C# array of floats

2009-11-04 Thread Daniel D .

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 Documentsipy 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


Re: [IronPython] Reproducing an C# array of floats

2009-11-04 Thread Dino Viehland
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 Documentsipy 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


Re: [IronPython] Reproducing an C# array of floats

2009-11-04 Thread Daniel D .

Hi Dino, thanks for the quick reply.

Now I'm using System.Single instead float but the error persists.

For some reason the Read (ref. http://is.gd/4Ngjt) method of 
SlimDX.DirectSound.CaptureBuffer isn't accepting the array reference properly.

Maybe I should try the Microsoft.DirextX.DirectSound lib, but it's been a 
little bit difficult to find good references about IronPython+DirectSound 
(probably by own  fault).
 

From: di...@microsoft.com
To: users@lists.ironpython.com
Date: Wed, 4 Nov 2009 20:20:35 +
Subject: Re: [IronPython] Reproducing an C# array of floats



















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 Documentsipy
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.



  
_
Windows Live Hotmail: Your friends can get your Facebook updates, right from 
Hotmail®.
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_4:092009___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Reproducing an C# array of floats

2009-11-04 Thread Dino Viehland
Ahh, read is a generic method and you're getting type inference from C# but not 
IronPython.  IronPython 2.6 includes type inference on generic methods so this 
might just work there, but otherwise I think you can do:

print buffer.Read[Single](sample, 0, True)

The square brackets are how we specifiy generic type parameters.

From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Daniel D.
Sent: Wednesday, November 04, 2009 12:48 PM
To: users@lists.ironpython.com
Subject: Re: [IronPython] Reproducing an C# array of floats

Hi Dino, thanks for the quick reply.

Now I'm using System.Single instead float but the error persists.

For some reason the Read (ref. http://is.gd/4Ngjt) method of 
SlimDX.DirectSound.CaptureBuffer isn't accepting the array reference properly.

Maybe I should try the Microsoft.DirextX.DirectSound lib, but it's been a 
little bit difficult to find good references about IronPython+DirectSound 
(probably by own  fault).


From: di...@microsoft.com
To: users@lists.ironpython.com
Date: Wed, 4 Nov 2009 20:20:35 +
Subject: Re: [IronPython] Reproducing an C# array of floats
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 Documentsipy 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


Windows Live Hotmail: Your friends can get your Facebook updates, right from 
Hotmail(r).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_4:092009
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Reproducing an C# array of floats

2009-11-04 Thread Daniel D .












Ahh, read is a generic method and you’re getting type inference
from C# but not IronPython.  IronPython 2.6 includes type inference on generic
methods so this might just work there, but otherwise I think you can do:

 

print
buffer.Read[Single](sample, 0, True)


 worked perfectly! thank you so much dino.



  
_
Windows Live: Keep your friends up to date with what you do online.
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_1:092010___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com