stsaz / fmedia

fast audio player/recorder/converter
BSD 2-Clause "Simplified" License
216 stars 21 forks source link

Record mode doesn't allow ouput device selection #81

Closed ITCMD closed 2 years ago

ITCMD commented 2 years ago

When running the following command:

fmedia.exe --dev=6 --record

I expect the microphone to stream input from the default microphone out to audio device #6, but instead, it streams to the default output device.

Explanation: --dev is not being considered when in record mode.

OS: Windows 11 Environment: Windows Batch File

fmedia is a perfect fit for an accessibility program I'm making for ham radio operators, but I really need this tag to work properly in record mode. If this can at all be rushed, I'd be forever grateful and would happily donate a coffee to the dev team.

Overall, amazing piece of software you've made. The ease of selecting devices and the intuitive TUI has been a total godsend.

Really wish I could offer a simple solution, but I'm lost in this language. I would assume you can just copy the --dev functionality from the simple playback mode over to record mode, but I'm sure it's not just that simple.

stsaz commented 2 years ago

Hi! Yes, this use-case is quite logical. I don't plan on releasing new features any time soon (there's a war going on which "my government" is involved in). But I can advise you on how to do it, because it's not that hard really:

    if (fmed->playdev_name != 0)
        qu_setval(qu, qe, "playdev_name", fmed->playdev_name);

The names in code are not the best (very old code), but playdev_name is actually --dev=N value.

        track->setval(trk, "capture_device", cmd->captdev_name);
if (cmd->playdev_name != 0)
track->setval(trk, "playdev_name", cmd->playdev_name);

This sets --dev=N value on the conveyer for this recording track, and audio-output filter will use it automatically. It should work, but I can't promise.

I'd be forever grateful and would happily donate a coffee to the dev team.

Heh, it's nice but it'd be somewhat difficult:) It's best if you could just tell someone else about fmedia - it would really support the project.

Overall, amazing piece of software you've made.

I'm glad you like it!

ITCMD commented 2 years ago

Gotchya, I appreciate it! For context, Im completely reworking this project and adding some new features like a live text-to-speech mode, easy saved recordings and playback, and a recording plugin to record both sides of the conversation individually. https://github.com/ITCMD/simple-radio-COM

I'll definitely be mentioning it on the program and in the code once it's done.

Thanks for the walkthrough! I'll work on figuring that out and add a compiled copy. I've never compiled anything before or used mingw before but, learning experience!

I'll probably throw the compiled version in here as well if github will let me. Overall, I appreciate your generous and understanding approach to this issue.

Also, didn't realize you were out of Russia. Sorry for what your government is putting you through, and sorry that we live in a world of such extremes; It's crazy to me that so many people can group an entire country of people under the ideal of their single dictatorial leader. But anyways, that's off-topic. My prayers are with you, stay safe!

ITCMD commented 2 years ago

I attempted to compile it but I appear to be getting a strange error: image (Note that I tried it in the src folder too. Same error). Says that fmedia.h isnt there when it is. Any tips? Here's the change I made: image

ITCMD commented 2 years ago

Seems like it requires a FFOS folder which isnt in your code? image

ITCMD commented 2 years ago

Ok so it looks like since all the dependencies are in <> not "", it's looking in my system folder instead of in the src folder?

Im unsure how to install all these dependencies.

Any tips?

ITCMD commented 2 years ago

I got stuck on the compile part so I tapped on some other C guys. Sorry but we couldn't figure out how to get your code to compile. Tried using the make file, gcc, and tried compiling it on windows and linux. Tried with and without the change.

If there's any chance you could compile that real quick for me, I'd be much appreciative, but I totally understand if you can't in the current climate you're working in.

Here it is edited (with .txt extension to make github happy) if that helps. main.c.txt

stsaz commented 2 years ago

Oh, it's not enough to just compile 1 .c file taken out from the rest of the project - you need to build it properly using the method described in README.md file - https://github.com/stsaz/fmedia/#build. You need to download dependent repositories and build with mingw64-make fmedia.exe. You can even skip step 3 because fmedia.exe file doesn't depend on anything. I usually compile fmedia on Linux, but building on Windows with mingw is the same thing, it works! (In fact, fmedia is MUCH easier to build than most other C projects where configure and automake scripts must first prepare the project for compilation!).

ITCMD commented 2 years ago

Alright, I gave that a try. I've cloned all the listed repositories in the same dir that fmedia is cloned into, and I ran C:\MinGW\bin\mingw32-make.exe fmedia.exe.

Here's my output:

process_begin: CreateProcess(NULL, uname, ...) failed.
../ffos/makeconf:13: pipe: No error
make: *** No rule to make target 'fmedia.exe'.  Stop.

I also tried making alib3 in case that was part of the problem:

G:\My Projects\Custom fmedia\fmedia>cd alib3

G:\My Projects\Custom fmedia\fmedia\alib3>make
C:/ProgramData/chocolatey/lib/make/tools/install/bin/make.exe -Rr -C ALAC
make[1]: Entering directory 'G:/My Projects/Custom fmedia/fmedia/alib3/ALAC'
curl -L -o master.zip https://github.com/macosforge/alac/archive/refs/heads/master.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 83035    0 83035    0     0   145k      0 --:--:-- --:--:-- --:--:--  145k
unzip -n master.zip
process_begin: CreateProcess(NULL, unzip -n master.zip, ...) failed.
make (e=2): The system cannot find the file specified.
make[1]: *** [Makefile:21: alac-master] Error 2
make[1]: Leaving directory 'G:/My Projects/Custom fmedia/fmedia/alib3/ALAC'
make: *** [Makefile:8: all] Error 2

Finally, I tried running the install command, hoping that that may make fmedia.exe as well, but it also failed:

G:\My Projects\Custom fmedia\fmedia>C:\MinGW\bin\mingw32-make.exe OS=win CPREFIX=x86_64-w64-mingw32- install

x86_64-w64-mingw32-gcc -c -pipe -std=gnu99 -fno-strict-aliasing -fvisibility=hidden -Wno-deprecated-declarations -DFFBASE_HAVE_FFERR_STR -g -O3 -flto -DFF_WIN_APIVER=0x0600 -m64 -march=x86-64 -msse4.2 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-stringop-overflow -I../fmedia/src -I../fmedia/alib3 -I../ffbase -I../ffaudio -I../avpack -I../ffos ../fmedia/src/crash.c -o crash.o
x86_64-w64-mingw32-gcc -c -pipe -std=gnu99 -fno-strict-aliasing -fvisibility=hidden -Wno-deprecated-declarations -DFFBASE_HAVE_FFERR_STR -g -O3 -flto -DFF_WIN_APIVER=0x0600 -m64 -march=x86-64 -msse4.2 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-stringop-overflow -I../fmedia/src -I../fmedia/alib3 -I../ffbase -I../ffaudio -I../avpack -I../ffos ../fmedia/src/main.c -o main.o
x86_64-w64-mingw32-gcc -c -pipe -std=gnu99 -fno-strict-aliasing -fvisibility=hidden -Wno-deprecated-declarations -DFFBASE_HAVE_FFERR_STR -g -O3 -flto -DFF_WIN_APIVER=0x0600 -m64 -march=x86-64 -msse4.2 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-stringop-overflow -I../fmedia/src -I../fmedia/alib3 -I../ffbase -I../ffaudio -I../avpack -I../ffos ../fmedia/src/util/ffos-compat/ffos.c -o ffos.o
x86_64-w64-mingw32-gcc -c -pipe -std=gnu99 -fno-strict-aliasing -fvisibility=hidden -Wno-deprecated-declarations -DFFBASE_HAVE_FFERR_STR -g -O3 -flto -DFF_WIN_APIVER=0x0600 -m64 -march=x86-64 -msse4.2 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-stringop-overflow -I../fmedia/src -I../fmedia/alib3 -I../ffbase -I../ffaudio -I../avpack -I../ffos ../fmedia/src/util/ffstring.c -o ffstring.o
x86_64-w64-mingw32-gcc -c -pipe -std=gnu99 -fno-strict-aliasing -fvisibility=hidden -Wno-deprecated-declarations -DFFBASE_HAVE_FFERR_STR -g -O3 -flto -DFF_WIN_APIVER=0x0600 -m64 -march=x86-64 -msse4.2 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-stringop-overflow -I../fmedia/src -I../fmedia/alib3 -I../ffbase -I../ffaudio -I../avpack -I../ffos ../fmedia/src/util/ffos-compat/ffwin.c -o ffwin.o
x86_64-w64-mingw32-gcc -c -pipe -std=gnu99 -fno-strict-aliasing -fvisibility=hidden -Wno-deprecated-declarations -DFFBASE_HAVE_FFERR_STR -g -O3 -flto -DFF_WIN_APIVER=0x0600 -m64 -march=x86-64 -msse4.2 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-stringop-overflow -I../fmedia/src -I../fmedia/alib3 -I../ffbase -I../ffaudio -I../avpack -I../ffos ../fmedia/src/afilter/ffpcm.c -o ffpcm.o
x86_64-w64-mingw32-windres -I../fmedia/src -I../ffbase -I../ffos ../fmedia/res/fmedia.rc fmedia.coff
process_begin: CreateProcess(NULL, x86_64-w64-mingw32-windres -I../fmedia/src -I../ffbase -I../ffos ../fmedia/res/fmedia.rc fmedia.coff, ...) failed.
make (e=2): The system cannot find the file specified.
Makefile:153: recipe for target 'fmedia.coff' failed
mingw32-make: *** [fmedia.coff] Error 2

Here's a tree of the folders in my build dir in case that helps you see what I'm doing wrong here.

tree "fmedia build dir"
Folder PATH listing for volume External Drive
Volume serial number is A4B6-7006
G:\MY PROJECTS\FMEDIA BUILD DIR
├───alsa-lib-master
│   ├───.github
│   │   └───workflows
│   ├───alsalisp
│   ├───aserver
│   ├───doc
│   │   └───pictures
│   ├───include
│   │   └───sound
│   │       └───uapi
│   ├───m4
│   ├───modules
│   │   └───mixer
│   │       └───simple
│   │           └───python
│   ├───src
│   │   ├───alisp
│   │   ├───conf
│   │   │   ├───cards
│   │   │   │   └───SI7018
│   │   │   ├───ctl
│   │   │   └───pcm
│   │   ├───control
│   │   ├───hwdep
│   │   ├───mixer
│   │   ├───pcm
│   │   │   └───scopes
│   │   ├───rawmidi
│   │   ├───seq
│   │   ├───timer
│   │   ├───topology
│   │   └───ucm
│   ├───test
│   │   ├───lsb
│   │   └───ucm
│   │       ├───anothercard
│   │       ├───testcard1
│   │       └───TestHDA
│   └───utils
├───avpack
│   ├───avpack
│   └───test
├───ffaudio
│   ├───ffaudio
│   ├───test
│   └───wav-player-example
├───ffbase
│   ├───doc
│   ├───ffbase
│   └───test
│       └───data
├───ffos
│   ├───echo-server-example
│   ├───FFOS
│   └───test
└───fmedia
    ├───.github
    │   └───workflows
    ├───.vscode
    ├───3pt
    │   └───crc
    ├───alib3
    │   ├───ALAC
    │   ├───DynamicAudioNormalizer
    │   ├───fdk-aac
    │   ├───FLAC
    │   ├───MAC
    │   ├───mp3lame
    │   ├───mpg123
    │   ├───musepack
    │   ├───ogg
    │   ├───opus
    │   ├───soxr
    │   ├───vorbis
    │   └───wavpack
    ├───android
    │   ├───app
    │   │   └───src
    │   │       └───main
    │   │           ├───java
    │   │           │   └───com
    │   │           │       └───github
    │   │           │           └───stsaz
    │   │           │               └───fmedia
    │   │           └───res
    │   │               ├───drawable
    │   │               ├───layout
    │   │               ├───menu
    │   │               ├───mipmap-anydpi-v26
    │   │               ├───mipmap-hdpi
    │   │               ├───mipmap-mdpi
    │   │               ├───mipmap-xhdpi
    │   │               ├───mipmap-xxhdpi
    │   │               ├───mipmap-xxxhdpi
    │   │               └───values
    │   └───gradle
    │       └───wrapper
    ├───doc
    │   ├───api-examples
    │   ├───arch
    │   ├───audio-convert
    │   └───recording
    ├───res
    └───src
        ├───acodec
        │   └───alib3-bridge
        ├───adev
        ├───afilter
        ├───core
        ├───format
        ├───gui-gtk
        ├───gui-winapi
        ├───net
        ├───plist
        └───util
            ├───ffos-compat
            ├───gui-gtk
            └───gui-winapi
ITCMD commented 2 years ago

One thing I noticed: image Are these required / possible to get on Windows?

ITCMD commented 2 years ago

Should this in the make file be conf vs coff? image

stsaz commented 2 years ago

You're very close to the victory, because I see that your mingw installation works fine! Now this would probably work:

mingw32-make.exe OS=win fmedia.exe

Edit: you have to apply this patch: ffos-makeconf.patch.txt

cd ffos
patch -p1 < ffos-makeconf.patch.txt
cd ..

This is an annoying difference in mingw on linux and windows - windres on windows is w/o prefix.

About the errors:

1.

process_begin: CreateProcess(NULL, uname, ...) failed. ../ffos/makeconf:13: pipe: No error

Use of OS=win is required now, though it's quite easy to fix in makeconf file. Or even better, start using new makeconf at ffos/test/makeconf2, but this will require some work...

2.

alib3>make make.exe -Rr -C ALAC unzip -n master.zip process_begin: CreateProcess(NULL, unzip -n master.zip, ...) failed. make (e=2): The system cannot find the file specified.

True, it's mandatory to have UNIX toolkit installed on Windows, but maybe some day my fcom app can do all this work on Windows...

3.

mingw32-make.exe OS=win CPREFIX=x86_64-w64-mingw32- x86_64-w64-mingw32-windres -I../fmedia/src -I../ffbase -I../ffos ../fmedia/res/fmedia.rc fmedia.coff process_begin: CreateProcess(NULL, x86_64-w64-mingw32-windres -I../fmedia/src -I../ffbase -I../ffos > ../fmedia/res/fmedia.rc fmedia.coff, ...) failed. make (e=2): The system cannot find the file specified.

That's because CPREFIX is only needed when compiling on Linux, but not on Windows.

Anyway, I'll try to add instructions into README.md about how to build fmedia on Windows, because it's not very straightforward, as it turns out. Or maybe you could write the building instructions (several short steps) yourself and send it via Pull Request? I would merge it into master branch.

ITCMD commented 2 years ago

Thanks for the tip! Still a couple more issues though I'm afraid.

Edit: you have to apply this patch: ffos-makeconf.patch.txt

cd ffos patch -p1 < ffos-makeconf.patch.txt cd ..

looks like patch isn't a command included with MinGW, however. Where would I find that?

Edit: Found it in GIT: "C:\Program Files\Git\usr\bin\patch.exe" -p1 < ffos-makeconf.patch.txt

It works! fmedia.zip

ITCMD commented 2 years ago

Created pull request in #82!

Actually my first ever pull request.