stsaz / fmedia

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

M1 support #90

Closed nicolai99 closed 1 year ago

nicolai99 commented 2 years ago

Does it support Apple M1 cpu?

stsaz commented 2 years ago

No, it doesn't. I don't have a toolkit for it, but I can provide you with the guidance on how to build fmedia (if you want). The only thing you will need is clang building tools and some time.

nicolai99 commented 2 years ago

I am not shure if i am able to build a application like this. I have basic skills from C/C++... but maybe i can try..

stsaz commented 2 years ago

I've prepared a script to automate the building process:

https://github.com/stsaz/fmedia/blob/autobuild/fmedia-autobuild.sh

Note that I didn't test it on macOS: please try to fix brew commands yourself if they don't work for you right away.

nicolai99 commented 1 year ago

thank you for that. Sorry for my late feedback. So i got a macMini M1 for testing. I got some problems - also with brew.

Should i post the problem ?

stsaz commented 1 year ago

Yes, just post here the output from your terminal, together we'll try to figure out what to do. Also, try to google on how to install brew, I'm sure it's possible on your mac.

nicolai99 commented 1 year ago

alac-master/codec/ag_enc.c:38:17: warning: 'TARGET_OS_MAC' is not defined, evaluates to 0 [-Wundef-prefix=TARGETOS]

if GNUC && TARGET_OS_MAC

            ^

alac-master/codec/ag_dec.c:37:17: warning: 'TARGET_OS_MAC' is not defined, evaluates to 0 [-Wundef-prefix=TARGETOS]

if GNUC && TARGET_OS_MAC

            ^

alac-master/codec/ALACDecoder.cpp:189:14: warning: variable 'samples' set but not used [-Wunused-but-set-variable] int16_t samples; ^ alac-master/codec/ALACEncoder.cpp:279:13: warning: variable 'denShift' set but not used [-Wunused-but-set-variable] uint32_t denShift; ^ alac-master/codec/ag_enc.c:101:38: warning: unused function 'read32bit' [-Wunused-function] static inline uint32_t ALWAYS_INLINE read32bit( uint8_t buffer ) ^ alac-master/codec/ALACDecoder.cpp:659:11: warning: variable 'element_instance_tag' set but not used [-Wunused-but-set-variable] uint8_t element_instance_tag; ^ alac-master/codec/ALACDecoder.cpp:38:16: warning: unused variable 'kMaxBitDepth' [-Wunused-const-variable] const uint32_t kMaxBitDepth = 32; // max allowed bit depth is 32 ^ alac-master/codec/ALACEncoder.cpp:559:13: warning: variable 'denShift' set but not used [-Wunused-but-set-variable] uint32_t denShift; ^ alac-master/codec/ALACEncoder.cpp:48:16: warning: unused variable 'kALACEncoderMagic' [-Wunused-const-variable] const uint32_t kALACEncoderMagic = 'dpge'; ^ alac-master/codec/ALACEncoder.cpp:94:23: warning: unused variable 'sSupportediPodSampleRates' [-Wunused-const-variable] static const uint32_t sSupportediPodSampleRates[] = ^ clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/dp_enc.c -o alac-master/codec/dp_enc.o clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/matrix_dec.c -o alac-master/codec/matrix_dec.o 2 warnings generated. 1 warning generated. clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/matrix_enc.c -o alac-master/codec/matrix_enc.o 3 warnings generated. 4 warnings generated. clang++ -fpic -Wl,-no-undefined -static-libgcc -Wl,-install_name -Wl,@loader_path/ -s -lm -static-libstdc++ -shared ALAC-ff.o alac-master/codec/ALACDecoder.o alac-master/codec/ALACEncoder.o alac-master/codec/EndianPortable.o alac-master/codec/ALACBitUtilities.o alac-master/codec/ag_dec.o alac-master/codec/ag_enc.o alac-master/codec/dp_dec.o alac-master/codec/dp_enc.o alac-master/codec/matrix_dec.o alac-master/codec/matrix_enc.o -o libALAC-ff.dylib clang: error: unsupported option '-static-libgcc' make[2]: [libALAC-ff.dylib] Error 1 make[1]: [all] Error 2 make: *** [all] Error 2

I think the warnings are no problem but the errors. At least brew is recognized now.

nicolai99 commented 1 year ago

fmedia-src.zip

this is the output folder. Maybe it helps to find out which parts are missing.

stsaz commented 1 year ago

clang: error: unsupported option '-static-libgcc'

Ah, clang on mac doesn't ignore gcc-only flags.

I've just added a fix for that to master branch, please run installer script once again on a clean working directory.

BTW, what did you do to install brew? Could you please provide some info so I can add it to installer script and documentation?

nicolai99 commented 1 year ago

alac-master/codec/ag_dec.c:37:17: warning: 'TARGET_OS_MAC' is not defined, evaluates to 0 [-Wundef-prefix=TARGETOS]

if GNUC && TARGET_OS_MAC

            ^

alac-master/codec/ag_enc.c:38:17: warning: 'TARGET_OS_MAC' is not defined, evaluates to 0 [-Wundef-prefix=TARGETOS]

if GNUC && TARGET_OS_MAC

            ^

alac-master/codec/ag_enc.c:101:38: warning: unused function 'read32bit' [-Wunused-function] static inline uint32_t ALWAYS_INLINE read32bit( uint8_t buffer ) ^ alac-master/codec/ALACEncoder.cpp:279:13: warning: variable 'denShift' set but not used [-Wunused-but-set-variable] uint32_t denShift; ^ alac-master/codec/ALACDecoder.cpp:189:14: warning: variable 'samples' set but not used [-Wunused-but-set-variable] int16_t samples; ^ alac-master/codec/ALACDecoder.cpp:659:11: warning: variable 'element_instance_tag' set but not used [-Wunused-but-set-variable] uint8_t element_instance_tag; ^ alac-master/codec/ALACDecoder.cpp:38:16: warning: unused variable 'kMaxBitDepth' [-Wunused-const-variable] const uint32_t kMaxBitDepth = 32; // max allowed bit depth is 32 ^ alac-master/codec/ALACEncoder.cpp:559:13: warning: variable 'denShift' set but not used [-Wunused-but-set-variable] uint32_t denShift; ^ alac-master/codec/ALACEncoder.cpp:48:16: warning: unused variable 'kALACEncoderMagic' [-Wunused-const-variable] const uint32_t kALACEncoderMagic = 'dpge'; ^ alac-master/codec/ALACEncoder.cpp:94:23: warning: unused variable 'sSupportediPodSampleRates' [-Wunused-const-variable] static const uint32_t sSupportediPodSampleRates[] = ^ clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/dp_enc.c -o alac-master/codec/dp_enc.o clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/matrix_dec.c -o alac-master/codec/matrix_dec.o clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/matrix_enc.c -o alac-master/codec/matrix_enc.o 1 warning generated. 2 warnings generated. 3 warnings generated. 4 warnings generated. clang++ -fpic -Wl,-no-undefined -Wl,-install_name -Wl,@loader_path/ -s -lm -static-libstdc++ -shared ALAC-ff.o alac-master/codec/ALACDecoder.o alac-master/codec/ALACEncoder.o alac-master/codec/EndianPortable.o alac-master/codec/ALACBitUtilities.o alac-master/codec/ag_dec.o alac-master/codec/ag_enc.o alac-master/codec/dp_dec.o alac-master/codec/dp_enc.o alac-master/codec/matrix_dec.o alac-master/codec/matrix_enc.o -o libALAC-ff.dylib clang: warning: argument unused during compilation: '-static-libstdc++' [-Wunused-command-line-argument] ld: warning: option -s is obsolete and being ignored ld: unknown option: -no-undefined clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [libALAC-ff.dylib] Error 1 make[1]: [all] Error 2 make: *** [all] Error 2

fmedia-src.zip

stsaz commented 1 year ago

ld: unknown option: -no-undefined

Fixed this and one more macos-related bug in makefile. Please retry. There's no need to attach src.zip files, it's all quite obvious with the error messages from clang.

nicolai99 commented 1 year ago

error: error: error: unknown FP unit 'sse'unknown FP unit 'sse'

unknown FP unit 'sse' make[2]: [DynamicAudioNormalizer-ff.o] Error 1 make[2]: Waiting for unfinished jobs.... error: unknown FP unit 'sse' make[2]: [DynamicAudioNormalizer-2.10/DynamicAudioNormalizerAPI/src/Version.o] Error 1 make[2]: [DynamicAudioNormalizer-2.10/DynamicAudioNormalizerAPI/src/GaussianFilter.o] Error 1 make[2]: [DynamicAudioNormalizer-2.10/DynamicAudioNormalizerAPI/src/FrameBuffer.o] Error 1 error: unknown FP unit 'sse' make[2]: [DynamicAudioNormalizer-2.10/DynamicAudioNormalizerAPI/src/DynamicAudioNormalizer.o] Error 1 make[1]: [all] Error 2 make: [all] Error 2

stsaz commented 1 year ago

error: unknown FP unit 'sse'

Nice! Fixed that. Please redownload the script (https://github.com/stsaz/fmedia/blob/autobuild/fmedia-autobuild.sh) as I made a small change to it (use autobuild branch instead of master until we fix all build problems).

nicolai99 commented 1 year ago

warning: warning: argument unused during compilation: '-msse' [-Wunused-command-line-argument]argument unused during compilation: '-msse' [-Wunused-command-line-argument]

clang: warning: argument unused during compilation: '-msse' [-Wunused-command-line-argument] DynamicAudioNormalizer-2.10/DynamicAudioNormalizerAPI/src/Version.cpp:130:3: error: Architecture is not supported!

error Architecture is not supported!

     ^

1 error generated. make[2]: [DynamicAudioNormalizer-2.10/DynamicAudioNormalizerAPI/src/Version.o] Error 1 make[2]: Waiting for unfinished jobs.... DynamicAudioNormalizer-2.10/DynamicAudioNormalizerAPI/src/DynamicAudioNormalizer.cpp:116:22: warning: unused function 'POW2' [-Wunused-function] static inline double POW2(const double &value) ^ DynamicAudioNormalizer-2.10/DynamicAudioNormalizerAPI/src/DynamicAudioNormalizer.cpp:176:11: warning: private field 'm_sampleCounterCompr' is not used [-Wunused-private-field] uint64_t m_sampleCounterCompr; ^ 2 warnings generated. make[1]: [all] Error 2 make: [all] Error 2 nicolaiglock@MinivonNicolai filemaker %

stsaz commented 1 year ago

error: Architecture is not supported!

It seems that DynamicAudioNormalizer doesn't support ARM, we'll just skip it for now...

OK, let's optimize the process a little bit. I've updated the fmedia-autobuild.sh script (please re-download it). Now it won't fail after encountering the first error but will try to build everything and log the progress into fmedia-build.log file. After the script finishes, please post fmedia-build.log here, so I can see all build errors at once. It will allow us to complete our task quicker.

nicolai99 commented 1 year ago

fmedia-build.log

stsaz commented 1 year ago

Great! Just a few more 3rd party libs left plus fmedia code itself... Please re-download fmedia-autobuild.sh script and attach new fmedia-build.log it generates.

nicolai99 commented 1 year ago

fmedia-build.log

stsaz commented 1 year ago

I think I fixed most of the stuff (except libDAN and libMAC modules which I just disabled), please repeat the above procedure. If the new log is fine, then we're almost done.

nicolai99 commented 1 year ago

fmedia-build.log

Great!

stsaz commented 1 year ago
nicolai99 commented 1 year ago

flac-1.3.3/src/libFLAC/stream_encoder.c:4086:72: warning: loop will run at most once (loop increment never executed) [-Wunreachable-code-loop-increment] for(partition_order = (int)max_partition_order; partition_order >= 0; partition_order--) { ^~~~~ clang -c -O3 -fpic -fvisibility=hidden -funroll-loops -I. -Iflac-1.3.3 -Iflac-1.3.3/src/libFLAC/include -Iflac-1.3.3/include -DHAVE_CONFIG_H -DFLAC_EXP -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wstrict-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wunreachable-code -Winline -Wdeclaration-after-statement -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-implicit-fallthrough flac-1.3.3/src/libFLAC/window.c -o flac-1.3.3/src/libFLAC/window.o flac-1.3.3/src/libFLAC/streamdecoder.c:2995:6: warning: code will never be executed [-Wunreachable-code] if(!decoder->private->is_seeking) ^~~ 1 warning generated. 1 warning generated. clang -shared FLAC-ff.o flac-1.3.3/src/libFLAC/bitmath.o flac-1.3.3/src/libFLAC/bitreader.o flac-1.3.3/src/libFLAC/bitwriter.o flac-1.3.3/src/libFLAC/cpu.o flac-1.3.3/src/libFLAC/crc.o flac-1.3.3/src/libFLAC/fixed.o flac-1.3.3/src/libFLAC/fixed_intrin_sse2.o flac-1.3.3/src/libFLAC/fixed_intrin_ssse3.o flac-1.3.3/src/libFLAC/float.o flac-1.3.3/src/libFLAC/format.o flac-1.3.3/src/libFLAC/lpc.o flac-1.3.3/src/libFLAC/lpc_intrin_sse.o flac-1.3.3/src/libFLAC/lpc_intrin_sse2.o flac-1.3.3/src/libFLAC/lpc_intrin_sse41.o flac-1.3.3/src/libFLAC/lpc_intrin_avx2.o flac-1.3.3/src/libFLAC/md5.o flac-1.3.3/src/libFLAC/memory.o flac-1.3.3/src/libFLAC/stream_decoder.o flac-1.3.3/src/libFLAC/stream_encoder.o flac-1.3.3/src/libFLAC/stream_encoder_intrin_sse2.o flac-1.3.3/src/libFLAC/stream_encoder_intrin_ssse3.o flac-1.3.3/src/libFLAC/stream_encoder_intrin_avx2.o flac-1.3.3/src/libFLAC/stream_encoder_framing.o flac-1.3.3/src/libFLAC/window.o -fpic -Wl,-install_name -Wl,@loader_path/libFLAC-ff.dylib -s -lm -o libFLAC-ff.dylib ld: warning: option -s is obsolete and being ignored /Library/Developer/CommandLineTools/usr/bin/make -Rr -C mp3lame curl -L -o lame-3.100.tar.gz https://jztkft.dl.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:00:07 --:--:-- 0 curl: (7) Failed to connect to jztkft.dl.sourceforge.net port 443 after 7121 ms: Network is unreachable make[1]: [lame-3.100.tar.gz] Error 7 make: [all] Error 2

fmedia/fmedia-1 doesn't exist...

stsaz commented 1 year ago

Heh, it's funny how SF server stopped responding. Moved archives to github. Now "Network is unreachable" error should be fixed.

nicolai99 commented 1 year ago

/Library/Developer/CommandLineTools/usr/bin/make -rR libwavpack-ff.dylib clang -c -O3 -fpic -fvisibility=hidden -I. -DWVPK_EXP -DHAVE_BUILTINCLZ=1 -DHAVEBUILTIN_CTZ=1 -DVER4_ONLY -DNO_SEEKING -DNO_TAGS -DNO_USE_FSTREAMS wavpack-4.75.0/src/common_utils.c -o wavpack-4.75.0/src/common_utils.o clang -c -O3 -fpic -fvisibility=hidden -I. -DWVPK_EXP -DHAVE_BUILTINCLZ=1 -DHAVEBUILTIN_CTZ=1 -DVER4_ONLY -DNO_SEEKING -DNO_TAGS -DNO_USE_FSTREAMS wavpack-4.75.0/src/decorr_utils.c -o wavpack-4.75.0/src/decorr_utils.o clang -c -O3 -fpic -fvisibility=hidden -I. -DWVPK_EXP -DHAVE_BUILTINCLZ=1 -DHAVEBUILTIN_CTZ=1 -DVER4_ONLY -DNO_SEEKING -DNO_TAGS -DNO_USE_FSTREAMS wavpack-4.75.0/src/entropy_utils.c -o wavpack-4.75.0/src/entropy_utils.o clang -c -O3 -fpic -fvisibility=hidden -I. -DWVPK_EXP -DHAVE_BUILTINCLZ=1 -DHAVEBUILTIN_CTZ=1 -DVER4_ONLY -DNO_SEEKING -DNO_TAGS -DNO_USE_FSTREAMS wavpack-4.75.0/src/open_utils.c -o wavpack-4.75.0/src/open_utils.o clang -c -O3 -fpic -fvisibility=hidden -I. -DWVPK_EXP -DHAVE_BUILTINCLZ=1 -DHAVEBUILTIN_CTZ=1 -DVER4_ONLY -DNO_SEEKING -DNO_TAGS -DNO_USE_FSTREAMS wavpack-4.75.0/src/read_words.c -o wavpack-4.75.0/src/read_words.o clang -c -O3 -fpic -fvisibility=hidden -I. -DWVPK_EXP -DHAVE_BUILTINCLZ=1 -DHAVEBUILTIN_CTZ=1 -DVER4_ONLY -DNO_SEEKING -DNO_TAGS -DNO_USE_FSTREAMS wavpack-4.75.0/src/unpack.c -o wavpack-4.75.0/src/unpack.o clang -c -O3 -fpic -fvisibility=hidden -I. -DWVPK_EXP -DHAVE_BUILTINCLZ=1 -DHAVEBUILTIN_CTZ=1 -DVER4_ONLY -DNO_SEEKING -DNO_TAGS -DNO_USE_FSTREAMS wavpack-4.75.0/src/unpack_floats.c -o wavpack-4.75.0/src/unpack_floats.o clang -c -O3 -fpic -fvisibility=hidden -I. -DWVPK_EXP -DHAVE_BUILTINCLZ=1 -DHAVEBUILTIN_CTZ=1 -DVER4_ONLY -DNO_SEEKING -DNO_TAGS -DNO_USE_FSTREAMS wavpack-4.75.0/src/unpack_utils.c -o wavpack-4.75.0/src/unpack_utils.o clang -shared wavpack-4.75.0/src/common_utils.o wavpack-4.75.0/src/decorr_utils.o wavpack-4.75.0/src/entropy_utils.o wavpack-4.75.0/src/open_utils.o wavpack-4.75.0/src/read_words.o wavpack-4.75.0/src/unpack.o wavpack-4.75.0/src/unpack_floats.o wavpack-4.75.0/src/unpack_utils.o -fpic -Wl,-install_name -Wl,@loader_path/libwavpack-ff.dylib -s -lm -o libwavpack-ff.dylib ld: warning: option -s is obsolete and being ignored

network error should be fixed. The fmedia/fmedia-1 directory is still missing.

stsaz commented 1 year ago

Oh, you need to install md5sum, please check if this works:

brew install md5sha1sum
cd fmedia-src/fmedia/alib3
make md5check
nicolai99 commented 1 year ago

nicolaiglock@MinivonNicolai alib3 % make md5check md5sum -c packages.md5 --ignore-missing Error: --check cannot be used with additional files make: *** [md5check] Error 255 nicolaiglock@MinivonNicolai alib3 %

stsaz commented 1 year ago

md5sum -c packages.md5 --ignore-missing Error: --check cannot be used with additional files

Well, I don't know how to verify md5 sums on macos then, so either try to find out how to do that, or just skip this step and continue with:

cd fmedia/alib3
make install
cd ../../

echo 'Building the app...'
cd fmedia
make -j8
cd ..

echo 'Checking...'
fmedia/fmedia-1/fmedia

(You already have all 3rd party libs built so there's no point to call the whole autobuild script again. Instead, you can just continue with building fmedia itself.)

nicolai99 commented 1 year ago

okay tried it, there were some errors..

after I execute make install

nicolaiglock@MinivonNicolai alib3 % make install mkdir -p _apple-arm64 cp -u ALAC/.dylib \ fdk-aac/.dylib \ FLAC/.dylib \ mp3lame/.dylib \ mpg123/.dylib \ musepack/.dylib \ ogg/.dylib \ opus/.dylib \ soxr/.dylib \ vorbis/.dylib \ wavpack/*.dylib \ _apple-arm64 cp: illegal option -- u usage: cp [-R [-H | -L | -P]] [-fi | -n] [-aclpsvXx] source_file target_file cp [-R [-H | -L | -P]] [-fi | -n] [-aclpsvXx] source_file ... target_directory make: *** [install] Error 64

after that i change direction to fmedia and execute make -j8:

ld: library not found for -lfdk-aac-ff clang: error: linker command failed with exit code 1 (use -v to see invocation) make: [aac.dylib] Error 1 make: Waiting for unfinished jobs.... ld: library not found for -lALAC-ff clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [alac.dylib] Error 1

stsaz commented 1 year ago

Yeah, OK. Now just use cp without -u option to copy all libs to _apple-arm64 directory manually:

cd fmedia/alib3
cp ALAC/*.dylib \
 fdk-aac/*.dylib \
 FLAC/*.dylib \
 mp3lame/*.dylib \
 mpg123/*.dylib \
 musepack/*.dylib \
 ogg/*.dylib \
 opus/*.dylib \
 soxr/*.dylib \
 vorbis/*.dylib \
 wavpack/*.dylib \
 _apple-arm64
cd ../../

echo 'Building the app...'
cd fmedia
make -j8
cd ..

echo 'Checking...'
fmedia/fmedia-1/fmedia
nicolai99 commented 1 year ago

it ends without errors but fmedia/fmedia-1/fmedia is still not there

nicolaiglock@MinivonNicolai _apple-arm64 % ls libALAC-ff.dylib libmpc-ff.dylib libsoxr-ff.dylib libFLAC-ff.dylib libmpg123-ff.dylib libvorbis-ff.dylib libfdk-aac-ff.dylib libogg-ff.dylib libvorbisenc-ff.dylib libmp3lame-ff.dylib libopus-ff.dylib libwavpack-ff.dylib

the cp function worked. The only thing I had to do was to make the direction _apple-arm64

the make -j8 instruction ends without errors.

stsaz commented 1 year ago

I somehow missed it in the latest version of autobuild script... The command should be make install. So now just do:

echo 'Building the app...'

cd fmedia
make -j8 install
cd ..

echo 'Checking...'
fmedia/fmedia-1/fmedia
nicolai99 commented 1 year ago

Yeah , the directory is now available. If I am in fmedia/fmedia-1/fmedia and type fmedia -h OR fmedia --help it returns

zsh: command not found: fmedia

stsaz commented 1 year ago

UNIX shell doesn't work this way, otherwise it would be insecure. Either call fmedia/fmedia-1/fmedia -h directly, or cd fmedia/fmedia-1 first and then ./fmedia -h. To be able to call fmedia -h you must add it to your $PATH for your shell program.