FluidSynth falha no script mas funciona no ipython

0

Estou começando a testar o uso do fluidSyinth para criar arquivos midi. Meu primeiro roteiro é muito simples. Funciona perfeitamente no ipython, mas não como um script na linha de comando, onde não faz nada, nem erros nem som. Eu estou usando python2.7 em ambos (ipython e linha de comando). Eu estou usando o Ubuntu. Este é o código:

#!/usr/bin/env python2.7
from mingus.midi import fluidsynth as c
import time

for i in range (0,100,1):
    c.play_Note(i,0,100)
    time.sleep(0.1)

Eu decidi testar o fluidsynth diretamente da linha de comando em um terminal do Ubuntu usando

fluidsynth /usr/share/sounds/sf2/FluidR3_GM.sf2 mymusicfile.mid

e eu tenho isso:

FluidSynth version 1.1.6
Copyright (C) 2000-2012 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of E-mu Systems, Inc.

Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
jackdmp 1.9.10
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2013 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
no message buffer overruns
no message buffer overruns
no message buffer overruns
JACK server starting in realtime mode with priority 10
audio_reservation_init
Acquire audio card Audio0
creating alsa driver ... hw:0|hw:0|1024|2|44100|0|0|nomon|swmeter|-|32bit
configuring for 44100Hz, period = 1024 frames (23.2 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
Type 'help' for help topics.

> 

mas o arquivo midi não é reproduzido, não deveria?

Este comando funciona bem no terminal ubuntu:

fluidsynth -a alsa -m alsa_seq -l -i /usr/share/sounds/sf2/FluidR3_GM.sf2 mymusicfile.midi

mas o problema permanece em python. O script que copiei no início deste encadeamento funciona bem no ipython, se eu o executar como:

run script.py

no entanto, ele não roda quando eu o executo a partir do terminal ubuntu na linha de comando como:

python2.7 script.py

Eu tentei o seguinte script que também funciona no ipython:

#!/usr/bin/env python2.7
import time
import fluidsynth

fs = fluidsynth.Synth()
fs.start()

sfid = fs.sfload("example.sf2")
fs.program_select(0, sfid, 0, 0)

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

time.sleep(1.0)

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

time.sleep(1.0)

fs.delete()

e recebo a seguinte saída quando eu o executo a partir do terminal ubuntu:

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jackdmp 1.9.10
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2013 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
no message buffer overruns
no message buffer overruns
no message buffer overruns
JACK server starting in realtime mode with priority 10
audio_reservation_init
Acquire audio card Audio0
creating alsa driver ... hw:0|hw:0|1024|2|44100|0|0|nomon|swmeter|-|32bit
configuring for 44100Hz, period = 1024 frames (23.2 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
JackTemporaryException : now quits...

embora não faça nenhum som.

    
por Ángel 04.11.2016 / 21:37

0 respostas