run aubiopitch continuously on a file descriptor

我们两清 提交于 2020-01-16 01:13:09

问题


I'd like to use aubiopitch to continuously output the frequency of a signal coming from an input source. Since aubiopitch likes to have its input be a file, not a stream, I tried using process substitution:

$ aubiopitch -i <(sox -q -d -t wav -)

I'd expect this to output the frequency of the signal being read off of my default audio input device. Instead, I got this:

./sox WARN wav: Length in output .wav header will be wrong since can't seek to fix it
AUBIO ERROR: source_apple_audio: Failed opening /dev/fd/63, error in ExtAudioFileOpenURL (-40)
AUBIO ERROR: source_wavread: could not find RIFF header in /dev/fd/63
AUBIO ERROR: source: failed creating aubio source with /dev/fd/63 at samplerate 0 with hop_size 256
Error: could not open input file /dev/fd/63

The problem doesn't seem to lie with sox, since this command works fine:

cat <(sox -q -d -t wav -) > output.wav

It creates an output.wav file that nothing seems to have trouble playing, except aubiopitch of course:

$ aubiopitch output.wav
Segmentation fault: 11

What's going on here? Is the issue with the RIFF header having the wrong length set?

If it matters, I'm running OSX 10.7.5 and I recompiled aubio to work with my older OSX version.


回答1:


$ sox -q -d -t wav - | aubiopitch -i -

When compiled with libsndfile support, '-' = stdin, so the above command could give the following output.

sox WARN wav: Length in output .wav header will be wrong since can't seek to fix it
0.000000 0.000000
0.005805 707.323486
0.011610 [...]

If you compiled aubio with more sources (avcodec or apple_audio), you will get more warnings. You can hide these warnings by redirecting stderr to /dev/null. Here is an example with aubioonset:

$ ( sox -q -d -t wav - | aubioonset -i - ) 2> /dev/null
0.000000
0.096871
0.279297
[...]


来源:https://stackoverflow.com/questions/26186132/run-aubiopitch-continuously-on-a-file-descriptor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!