sinneb / pyfluidsynth

Automatically exported from code.google.com/p/pyfluidsynth
1 stars 0 forks source link

Memory Corruption while trying to run example which uses pyaudio #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. running example code which uses pyaudio

What is the expected output? What do you see instead?
I want to hear the chord. i see an error saying memory corruption.

What version of the product are you using? On what operating system?
1.2.4 on Ubuntu Jaunty 64 bit

Please provide any additional information below.
This is the error:
(Mon Oct 12 18:56:38) corleone@corleone-desktop:~$ python
myfirstpyfluidsynth.py 
fluidsynth: warning: Failed to pin the sample data to RAM; swapping is
possible.
176400
Starting playback
*** glibc detected *** python: malloc(): memory corruption:
0x00000000014595f0 ***
======= Backtrace: =========
/lib/libc.so.6[0x7f98320affef]
/lib/libc.so.6(__libc_malloc+0x98)[0x7f98320b1828]
/usr/lib/libpulse.so.0(pa_xrealloc+0x17)[0x7f982d61e6a7]
/usr/lib/libpulse.so.0[0x7f982d63aaa9]
/usr/lib/libpulse.so.0[0x7f982d604976]
/usr/lib/libpulse.so.0(pa_stream_cork+0x8f)[0x7f982d616bcf]
/usr/lib/alsa-lib/libasound_module_pcm_pulse.so[0x7f982d85c7ad]
/usr/lib/libasound.so.2[0x7f982ed09bce]
/usr/lib/libasound.so.2[0x7f982eccaa56]
/usr/lib/libasound.so.2[0x7f982ed09b4a]
/usr/lib/libportaudio.so.2[0x7f982f16f977]
/usr/lib/libportaudio.so.2[0x7f982f17085a]
/usr/lib/libportaudio.so.2[0x7f982f170bf7]
/usr/local/lib/python2.6/dist-packages/_portaudio.so[0x7f982f38bc8c]
python(PyEval_EvalFrameEx+0x4e23)[0x4a2b03]
python(PyEval_EvalCodeEx+0x869)[0x4a4649]
python(PyEval_EvalFrameEx+0x4fd0)[0x4a2cb0]
python(PyEval_EvalCodeEx+0x869)[0x4a4649]
python(PyEval_EvalCode+0x32)[0x4a4762]
python(PyRun_FileExFlags+0x13c)[0x4c4c3c]
python(PyRun_SimpleFileExFlags+0x1fb)[0x4c4f6b]
python(Py_Main+0xb9e)[0x4189ce]
/lib/libc.so.6(__libc_start_main+0xe6)[0x7f98320535a6]
python[0x417ae9]
======= Memory map: ========
00400000-00616000 r-xp 00000000 08:05 834187                            
/usr/bin/python2.6
00815000-00816000 r--p 00215000 08:05 834187                            
/usr/bin/python2.6
00816000-00876000 rw-p 00216000 08:05 834187                            
/usr/bin/python2.6
00876000-00885000 rw-p 00876000 00:00 0 
0104a000-014e8000 rw-p 0104a000 00:00 0                                  [heap]
7f9823a98000-7f9827a99000 rw-s 00000000 00:15 4777660                   
/dev/shm/pulse-shm-2345148384
7f9827a99000-7f9827a9a000 ---p 7f9827a99000 00:00 0 
7f9827a9a000-7f982829a000 rw-p 7f9827a9a000 00:00 0 
7f982b84e000-7f982b8fb000 rw-p 7f982b84e000 00:00 0 
7f982ba3d000-7f982ba49000 r-xp 00000000 08:05 1338452                   
/lib/libnss_files-2.9.so
7f982ba49000-7f982bc48000 ---p 0000c000 08:05 1338452                   
/lib/libnss_files-2.9.so
7f982bc48000-7f982bc49000 r--p 0000b000 08:05 1338452                   
/lib/libnss_files-2.9.so
7f982bc49000-7f982bc4a000 rw-p 0000c000 08:05 1338452                   
/lib/libnss_files-2.9.so
7f982bc4a000-7f982bc54000 r-xp 00000000 08:05 1338454                   
/lib/libnss_nis-2.9.so
7f982bc54000-7f982be53000 ---p 0000a000 08:05 1338454                   
/lib/libnss_nis-2.9.so
7f982be53000-7f982be54000 r--p 00009000 08:05 1338454                   
/lib/libnss_nis-2.9.so
7f982be54000-7f982be55000 rw-p 0000a000 08:05 1338454                   
/lib/libnss_nis-2.9.so
7f982be55000-7f982be6b000 r-xp 00000000 08:05 1338447                   
/lib/libnsl-2.9.so
7f982be6b000-7f982c06b000 ---p 00016000 08:05 1338447                   
/lib/libnsl-2.9.so
7f982c06b000-7f982c06c000 r--p 00016000 08:05 1338447                   
/lib/libnsl-2.9.so
7f982c06c000-7f982c06d000 rw-p 00017000 08:05 1338447                   
/lib/libnsl-2.9.so
7f982c06d000-7f982c06f000 rw-p 7f982c06d000 00:00 0 
7f982c06f000-7f982c077000 r-xp 00000000 08:05 1338449                   
/lib/libnss_compat-2.9.so
7f982c077000-7f982c276000 ---p 00008000 08:05 1338449                   
/lib/libnss_compat-2.9.so
7f982c276000-7f982c277000 r--p 00007000 08:05 1338449                   
/lib/libnss_compat-2.9.so
7f982c277000-7f982c278000 rw-p 00008000 08:05 1338449                   
/lib/libnss_compat-2.9.so
7f982c29b000-7f982c2a0000 r-xp 00000000 08:05 836052                    
/usr/lib/libXdmcp.so.6.0.0
7f982c2a0000-7f982c49f000 ---p 00005000 08:05 836052                    
/usr/lib/libXdmcp.so.6.0.0
7f982c49f000-7f982c4a0000 rw-p 00004000 08:05 836052                    
/usr/lib/libXdmcp.so.6.0.0
7f982c4a0000-7f982c4a2000 r-xp 00000000 08:05 836050                    
/usr/lib/libXau.so.6.0.0
7f982c4a2000-7f982c6a1000 ---p 00002000 08:05 836050                    
/usr/lib/libXau.so.6.0.0
7f982c6a1000-7f982c6a2000 r--p 00001000 08:05 836050                    
/usr/lib/libXau.so.6.0.0
7f982c6a2000-7f982c6a3000 rw-p 00002000 08:05 836050                    
/usr/lib/libXau.so.6.0.0
7f982c6a3000-7f982c6a7000 r-xp 00000000 08:05 1338250                   
/lib/libattr.so.1.1.0
7f982c6a7000-7f982c8a6000 ---p 00004000 08:05 1338250                   
/lib/libattr.so.1.1.0
7f982c8a6000-7f982c8a7000 r--p 00003000 08:05 1338250                   
/lib/libattr.so.1.1.0
7f982c8a7000-7f982c8a8000 rw-p 00004000 08:05 1338250                   
/lib/libattr.so.1.1.0
7f982c8a8000-7f982c8c3000 r-xp 00000000 08:05 836054                    
/usr/lib/libxcb.so.1.1.0
7f982c8c3000-7f982cac2000 ---p 0001b000 08:05 836054                    
/usr/lib/libxcb.so.1.1.0
7f982cac2000-7f982cac3000 r--p 0001a000 08:05 836054                    
/usr/lib/libxcb.so.1.1.0
7f982cac3000-7f982cac4000 rw-p 0001b000 08:05 836054                    
/usr/lib/libxcb.so.1.1.0
7f982cac4000-7f982cac9000 r-xp 00000000 08:05 834837                    
/usr/lib/libgdbm.so.3.0.0
7f982cac9000-7f982ccc8000 ---p 00005000 08:05 834837                    
/usr/lib/libgdbm.so.3.0.0
7f982ccc8000-7f982ccc9000 r--p 00004000 08:05 834837                    
/usr/lib/libgdbm.so.3.0.0
7f982ccc9000-7f982ccca000 rw-p 00005000 08:05 834837                    
/usr/lib/libgdbm.so.3.0.0
7f982ccca000-7f982ccce000 r-xp 00000000 08:05 1338393                   
/lib/libcap.so.2.11
7f982ccce000-7f982cecd000 ---p 00004000 08:05 1338393                   
/lib/libcap.so.2.11
7f982cecd000-7f982cece000 r--p 00003000 08:05 1338393                   
/lib/libcap.so.2.11
7f982cece000-7f982cecf000 rw-p 00004000 08:05 1338393                   
/lib/libcap.so.2.11
7f982cecf000-7f982cfd1000 r-xp 00000000 08:05 836056                    
/usr/lib/libX11.so.6.2.0
7f982cfd1000-7f982d1d1000 ---p 00102000 08:05 836056                    
/usr/lib/libX11.so.6.2.0
7f982d1d1000-7f982d1d2000 r--p 00102000 08:05 836056                    
/usr/lib/libX11.so.6.2.0
7f982d1d2000-7f982d1d6000 rw-p 00103000 08:05 836056                    
/usr/lib/libX11.so.6.2.0
7f982d1d6000-7f982d1ed000 r-xp 00000000 08:05 836068                    
/usr/lib/libICE.so.6.3.0
7f982d1ed000-7f982d3ec000 ---p 00017000 08:05 836068                    
/usr/lib/libICE.so.6.3.0
7f982d3ec000-7f982d3ee000 rw-p 00016000 08:05 836068                    
/usr/lib/libICE.so.6.3.0
7f982d3ee000-7f982d3f1000 rw-p 7f982d3ee000 00:00 0 
7f982d3f1000-7f982d3f9000 r-xp 00000000 08:05 836070                    
/usr/lib/libSM.so.6.0.0
7f982d3f9000-7f982d5f8000 ---p 00008000 08:05 836070                    
/usr/lib/libSM.so.6.0.0
7f982d5f8000-7f982d5f9000 r--p 00007000 08:05 836070                    
/usr/lib/libSM.so.6.0.0
7f982d5f9000-7f982d5fa000 rw-p 00008000 08:05 836070                    
/usr/lib/libSM.so.6.0.0
7f982d5fa000-7f982d657000 r-xp 00000000 08:05 1152122                   
/usr/lib/libpulse.so.0.7.1
7f982d657000-7f982d857000 ---p 0005d000 08:05 1152122                   
/usr/lib/libpulse.so.0.7.1
7f982d857000-7f982d858000 r--p 0005d000 08:05 1152122                   
/usr/lib/libpulse.so.0.7.1
7f982d858000-7f982d859000 rw-p 0005e000 08:05 1152122                   
/usr/lib/libpulse.so.0.7.1
7f982d859000-7f982d85f000 r-xp 00000000 08:05 884214                    
/usr/lib/alsa-lib/libasound_module_pcm_pulse.so
7f982d85f000-7f982da5e000 ---p 00006000 08:05 884214                    
/usr/lib/alsa-lib/libasound_module_pcm_pulse.so
7f982da5e000-7f982da5f000 r--p 00005000 08:05 884214                    
/usr/lib/alsa-lib/libasound_module_pcm_pulse.so
7f982da5f000-7f982da60000 rw-p 00006000 08:05 884214                    
/usr/lib/alsa-lib/libasound_module_pcm_pulse.so
7f982da60000-7f982da6e000 r-xp 00000000 08:05 1151783                   
/usr/lib/libcelt.so.0.0.0
7f982da6e000-7f982dc6d000 ---p 0000e000 08:05 1151783                   
/usr/lib/libcelt.so.0.0.0
7f982dc6d000-7f982dc6e000 r--p 0000d000 08:05 1151783                   
/usr/lib/libcelt.so.0.0.0
7f982dc6e000-7f982dc6f000 rw-p 0000e000 08:05 1151783                   
/usr/lib/libcelt.so.0.0.0
7f982dc6f000-7f982ddd8000 r-xp 00000000 08:05 839687                    
/usr/lib/libsamplerate.so.0.1.4
7f982ddd8000-7f982dfd7000 ---p 00169000 08:05 839687                    
/usr/lib/libsamplerate.so.0.1.4
7f982dfd7000-7f982dfd8000Aborted

This is the code: 
import time
import numpy
import pyaudio
import fluidsynth

pa = pyaudio.PyAudio()
strm = pa.open(
    format = pyaudio.paInt16,
    channels = 2, 
    rate = 44100, 
    output = True)

s = []

fl = fluidsynth.Synth()

# Initial silence is 1 second
s = numpy.append(s, fl.get_samples(44100 * 1))

sfid = fl.sfload("Guitar_FX.sf2")
fl.program_select(0, sfid, 0, 0)

fl.noteon(0, 60, 30)
fl.noteon(0, 67, 30)
fl.noteon(0, 76, 30)

# Chord is held for 2 seconds
s = numpy.append(s, fl.get_samples(44100 * 2))

fl.noteoff(0, 60)
fl.noteoff(0, 67)
fl.noteoff(0, 76)

# Decay of chord is held for 1 second
s = numpy.append(s, fl.get_samples(44100 * 1))

fl.delete()

samps = fluidsynth.raw_audio_string(s)

print len(samps)
print 'Starting playback'
strm.write(samps)

Original issue reported on code.google.com by david.mt...@gmail.com on 13 Oct 2009 at 12:05

GoogleCodeExporter commented 9 years ago
Hi David, I'm not exactly sure what's happening and I can't currently test it 
because
I haven't got the pyaudio module installed, but what I think is causing 
problems is:

   fl.delete()

Before calling:

    samps = fluidsynth.raw_audio_string(s)

What happens when you swap those lines?

Original comment by Rhijnauwen@gmail.com on 13 Oct 2009 at 5:25

GoogleCodeExporter commented 9 years ago
Thanks for your quick answer.

I switched those lines an i am still getting the same error.

Original comment by david.mt...@gmail.com on 13 Oct 2009 at 6:12

GoogleCodeExporter commented 9 years ago
I get the same thing running this example and I also get the same problem when 
running other example pyaudio stuff. The problem definitely with pyaudio. Did 
you ever find a solution to this David?

Original comment by davidgrant on 30 Sep 2010 at 2:53

GoogleCodeExporter commented 9 years ago
I was having a similar problem with pyaudio.  My solution was to change the 
chunk size (see the "Play a WAVE file" example in pyaudio).  I had set a large 
chunk size of 16384, but setting it back to 1024 or 2048 made this problem go 
away.  

Original comment by charlesb...@gmail.com on 6 Nov 2011 at 9:52