1

I'm setting an audio program on my raspberry using libsox, the developer library of SoX. And for instance I need to make it play my input mp3 file to my stdout output so I can hear the song with my earpiece connected to the jack port of the raspberry.

So I used this code, but the "-" in the filetype of the function "sox_open_write()" doesn't transfer my song into the stdout. I got this error:

no handler for given file type -' exe1: example1.c:99: main: Assertionin = sox_open_read(argv[1], NULL, >> NULL,"-")' failed.

Here is the code :

https://github.com/dmkrepo/libsox/blob/master/src/example1.c#L145

I've tried to output the audio into another file and it is working. Also tried to look at the function original developper made in fossies libsox website.

assert(out = sox_open_write(argv[2], &in->signal, NULL, "-", NULL, NULL));

For instance I just changed one of the parameter of the function. In the manual it's supposed to transfer the audio file to stdout output. But an error occurs

I just expect the program to play a single song.

Nie Lie
  • 11
  • 1
  • 1
    [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) isn't the audio output port. If all you want to do is play an mp3 file, have you tried `omxplayer`? Can you play a `.wav` file using the `play` program included with `sox`? – jamieguinan Apr 22 '19 at 00:32
  • Actually I need it to stop or play the song when someone cross the capter connected to the raspberry. That's why I'm making it in c. In the manual it is said that for the function **"sox_open_output"**. **A special name of "-" can be used to write data to stdout, though stdout.** And yes play works but I can't use the terminal when the song is playing. – Nie Lie Apr 22 '19 at 08:41

0 Answers0