943,958 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 451
  • Python RSS
May 22nd, 2009
0

The "sound" of the brain...?

Expand Post »
So, as a scientist, I have plenty of geeky friends... and one of them is interested in creating a sound file from the brain waves she records. Essentially, she has a brain wave, and wants to feed it into a sound program to play it as if it were a sound wave.

Does anyone know of a program like this, or possibly a way to do it using python? I only ask here because I don't know of a better forum for this question, and if the answer is available in python I might be able to code something up for her.

Cheers!
Similar Threads
aot
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
aot is offline Offline
83 posts
since Feb 2007
May 22nd, 2009
0

Re: The "sound" of the brain...?

just curious, whose brain waves has she recorded? I would like to hear my brain sound later if you succeed Cool!!
Reputation Points: 10
Solved Threads: 1
Light Poster
names24 is offline Offline
45 posts
since Jul 2007
May 22nd, 2009
0

Re: The "sound" of the brain...?

What format are the recorded waves in? A binary stream, or?
Featured Poster
Reputation Points: 975
Solved Threads: 140
Posting Virtuoso
scru is offline Offline
1,624 posts
since Feb 2007
May 22nd, 2009
0

Re: The "sound" of the brain...?

Ah yes. Technically they record it in analog and convert to digital, so she could theoretically provide either format. Although I don't know the specific file type that she uses, I can find out. At the least it would be possible to take a screenshot of the wave.
Last edited by aot; May 22nd, 2009 at 10:15 am.
aot
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
aot is offline Offline
83 posts
since Feb 2007
May 22nd, 2009
0

Re: The "sound" of the brain...?

I don't know of any program that does exactly this, but maybe you can search for one that transforms binary data into a wave file (or at least how). If you're feeling particularly ambitious, you can even write a script that transforms the data from scratch: http://ccrma.stanford.edu/courses/42...ts/WaveFormat/
Featured Poster
Reputation Points: 975
Solved Threads: 140
Posting Virtuoso
scru is offline Offline
1,624 posts
since Feb 2007
May 22nd, 2009
0

Re: The "sound" of the brain...?

Look into Python modules audioop and sunaudiodev
Sun's .au audio file format is rather simple and flexible. Here is an example that vegaseat left some time ago, it shows you how to create an .au files from scratch:
python Syntax (Toggle Plain Text)
  1. # create a soundfile in AU format playing a sine wave
  2. # of a given frequency, duration and volume
  3. # tested with Python25 by vegaseat 29jan2008
  4.  
  5. from struct import pack
  6. from math import sin, pi
  7.  
  8. def au_file(name='test.au', freq=440, dur=1000, vol=0.5):
  9. """
  10. creates an AU format audio file of a sine wave
  11. of frequency freq (Hz)
  12. for duration dur (milliseconds)
  13. at volume vol (max is 1.0)
  14. """
  15. fout = open(name, 'wb')
  16. # header needs size, encoding=2, sampling_rate=8000, channel=1
  17. fout.write('.snd' + pack('>5L', 24, 8*dur, 2, 8000, 1))
  18. factor = 2 * pi * freq/8000
  19. # write data
  20. for seg in range(8 * dur):
  21. # sine wave calculations
  22. sin_seg = sin(seg * factor)
  23. fout.write(pack('b', vol * 127 * sin_seg))
  24. fout.close()
  25.  
  26. # test the module ...
  27. if __name__ == '__main__':
  28. au_file(name='sound800.au', freq=800, dur=2000, vol=0.8)
  29.  
  30. # if you have Windows, you can test the audio file
  31. # otherwise comment this code out
  32. import os
  33. os.startfile('sound800.au')
I think the webbrowser module allows you to play .au files too.
Last edited by sneekula; May 22nd, 2009 at 2:49 pm.
Reputation Points: 961
Solved Threads: 211
Nearly a Posting Maven
sneekula is offline Offline
2,413 posts
since Oct 2006
May 24th, 2009
0

Re: The "sound" of the brain...?

..and if you convert to square waves......
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Bill Fisher is offline Offline
4 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: JSON Library
Next Thread in Python Forum Timeline: Pygame logic problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC