Coder Social home page Coder Social logo

musializer's Introduction

Musializer

Warning

This software is unfinished. Keep your expectations low.

The project aims to make a tool for creating beautiful music visualizations and rendering high quality videos of them.

Please, read CONTRIBUTING.md before making a PR.

Demo

Music by @nu11 from https://soundcloud.com/nu11_ft/nu11-wip-works-2016-2022 at 20:38

output.mp4

Supported Audio Formats

  • wav
  • ogg
  • mp3
  • qoa
  • xm
  • mod
  • flac

Download Binaries

Build from Source

External Dependencies:

  • ffmpeg executable available in PATH environment variable. It is called as a child process during the rendering of the videos. So if you don't plan to render any videos it's completely optional.

We are using Custom Build System written entirely in C called nob. It is similar to nobuild in spirit. nob.h is the Build System and nob.c is the program that builds Musializer.

Before using nob you need to bootstrap it. Just compile it with the available C compiler. On Linux it's usually $ cc -o nob nob.c on Windows with MSVC from within vcvarsall.bat it's $ cl.exe nob.c. You only need to boostrap it once. After the bootstrap you can just keep running the same executable over and over again. It even tries to rebuild itself if you modify nob.c (which may fail sometimes, so in that case be ready to reboostrap it).

I really recommend to read nob.c and nob.h to get an idea of how it all actually works. The Build System is a work in progress, so if something breaks be ready to dive into it.

Linux and OpenBSD

$ cc -o nob nob.c # ONLY ONCE!!!
$ ./nob
$ ./build/musializer

If the build fails because of missing header files, you may need to install the X11 dev packages.

On Debian, Ubuntu, etc, do this:

$ sudo apt install libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev

On other distro's, use the appropriate package manager.

Windows MSVC

From within vcvarsall.bat do

> cl.exe nob.c # ONLY ONCE!!!
> nob.exe
> build\musializer.exe

Cross Compilation from Linux to Windows using MinGW-w64

Install MinGW-w64 from your distro repository.

Edit ./build/config.h and set MUSIALIZER_TARGET_WIN64_MINGW instead of MUSIALIZER_TARGET_LINUX.

$ ./nob
$ wine ./build/musializer.exe

Hot Reloading

Edit ./build/config.h and enable MUSIALIZER_HOTRELOAD.

$ ./nob
$ ./build/musializer

Keep the app running. Rebuild with ./nob. Hot reload by focusing on the window of the app and pressing h.

The way it works is by putting the majority of the logic of the application into a libplug dynamic library and just reloading it when requested. The rpath (aka hard-coded run-time search path) for that library is set to . and ./build/. See src/nob_linux.c for more information on how everything is configured.

musializer's People

Contributors

abhra0897 avatar amalirfan avatar anaskorichi999 avatar auxves avatar brvtalcake avatar chronomonochrome avatar davehorner avatar drobotk avatar gstaaij avatar hkhademian avatar ismagilli avatar jgabaut avatar lainlayer avatar lookins01 avatar lulzshadowwalker avatar m4c0 avatar markos-th09 avatar ratchetfreak avatar rexim avatar shaqeelahmad avatar sobieg avatar tpby2005 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

musializer's Issues

Windows build support

i cant remember how last time i compiled using msys2 mingw but with the new build system it's not building

**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.8.1
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\Program Files\Microsoft Visual Studio\2022\Community>cd \Users\Administrator\Documents\github

C:\Users\Administrator\Documents\github>git clone --recursive https://github.com/tsoding/musializer.git
Cloning into 'musializer'...
remote: Enumerating objects: 1257, done.
remote: Counting objects: 100% (410/410), done.
remote: Compressing objects: 100% (88/88), done.
Receiving objects: 100% (1257/1257), 2.98 MiB | 120.00 KiB/s, done. 847

Resolving deltas: 100% (740/740), done.

C:\Users\Administrator\Documents\github>cd musializer

C:\Users\Administrator\Documents\github\musializer>cl nob.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.37.32825 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

nob.c
Microsoft (R) Incremental Linker Version 14.37.32825.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:nob.exe
nob.obj

C:\Users\Administrator\Documents\github\musializer>nob.exe
[INFO] --- STAGE 1 ---
[INFO] created directory `build`
[INFO] Generating ./build/config.h
[INFO] CMD: cl.exe nob.c -DCONFIGURED
Microsoft (R) C/C++ Optimizing Compiler Version 19.37.32825 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

nob.c
Microsoft (R) Incremental Linker Version 14.37.32825.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:nob.exe
nob.obj
LINK : fatal error LNK1104: cannot open file 'nob.exe'
[ERROR] command exited with exit code 2

[WINDOWS] Lack of optimization

The program uses too many CPU for music. sometimes even 10% of my CPU, it's even more than Windows's anti malware.
image

Would be great to optimize the program to use less CPU

Support rendering video for all supported file formats

I just spent a lot of time to find out why it did not render my video. The reason is, that ".mod" files are supported for Visualisation but LoadWave() in Raylib does not support them. The function succeeds albeit while burying the message "WARNING: WAVE: Data format not supported" in the logs.

Could we either add support for these files separately or check whether the file extension is supported with a user facing error if not before calling LoadWave().

Cyrillic in the path to the audio leads to no playback

Linux.

I have a symlink for my Music etc folder called Всё для треков и тд, if i drag n drop music from the Music etc - it works perfectly, even if the filename of the audio itself is in Cyrillic. However, if i drag n drop music from the symlink Всё для треков и тд - the audio just glitches out and no visualization happens at all.

I assume this is an issue with Cyrillic in the path to the file specifically, not the links. After long testing i found out that any combination of symlinking audio and the path to the audio if the file's path is not in Cyrillic leads to standard behavior.

bootstrap process in shell:

INFO: Initializing raylib 5.0
INFO: Platform backend: DESKTOP (GLFW)
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 1920 x 1080
INFO:     > Screen size:  1280 x 720
INFO:     > Render size:  1280 x 720
INFO:     > Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: GL: Supported extensions count: 400
INFO: GL: OpenGL device information:
INFO:     > Vendor:   NVIDIA Corporation
INFO:     > Renderer: NVIDIA GeForce RTX 3060/PCIe/SSE2
INFO:     > Version:  3.3.0 NVIDIA 550.67
INFO:     > GLSL:     3.30 NVIDIA via Cg compiler
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: DXT compressed textures supported
INFO: GL: ETC2/EAC compressed textures supported
INFO: PLATFORM: DESKTOP (GLFW): Initialized successfully
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
INFO: IMAGE: Data loaded successfully (256x256 | R8G8B8A8 | 1 mipmaps)
INFO: TIMER: Target time per frame: 16.667 milliseconds
INFO: AUDIO: Device initialized successfully
INFO:     > Backend:       miniaudio / PulseAudio
INFO:     > Format:        32-bit IEEE Floating Point -> 32-bit Signed Integer
INFO:     > Channels:      2 -> 2
INFO:     > Sample rate:   48000 -> 48000
INFO:     > Periods size:  3600
INFO: TEXTURE: [ID 3] Texture loaded successfully (1024x512 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (64 pixel size | 95 glyphs)
INFO: TEXTURE: [ID 3] Mipmaps generated automatically, total: 11
INFO: SHADER: [ID 4] Fragment shader compiled successfully
INFO: SHADER: [ID 5] Program shader loaded successfully
INFO: TEXTURE: [ID 4] Texture loaded successfully (1600x900 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Depth renderbuffer loaded successfully (32 bits)

Output in the shell when trying to open a file located in a folder with Cyrillic name:

INFO: FBO: [ID 1] Framebuffer object created successfully
INFO: STREAM: Initialized successfully (44100 Hz, 24 bit, Stereo)
INFO: FILEIO: [/kirby/Всё для треков и тд/fade_away.flac] Music file loaded successfully
INFO:     > Sample rate:   44100 Hz
INFO:     > Sample size:   24 bits
INFO:     > Channels:      2 (Stereo)
INFO:     > Total frames:  13582209
INFO: IMAGE: Data loaded successfully (1024x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 5] Texture loaded successfully (1024x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 5] Mipmaps generated automatically, total: 11
INFO: IMAGE: Data loaded successfully (512x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 6] Texture loaded successfully (512x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 6] Mipmaps generated automatically, total: 10
INFO: IMAGE: Data loaded successfully (1536x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 7] Texture loaded successfully (1536x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 7] Mipmaps generated automatically, total: 11
INFO: IMAGE: Data loaded successfully (2048x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 8] Texture loaded successfully (2048x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 8] Mipmaps generated automatically, total: 12

when loading from the non-Cyrillic folder:

INFO: FILEIO: [/kirby/Music etc/fade_away.flac] Music file loaded successfully
INFO:     > Sample rate:   44100 Hz
INFO:     > Sample size:   24 bits
INFO:     > Channels:      2 (Stereo)
INFO:     > Total frames:  13582209

[Feature Request] let speaker output be an option

Feel free to close this if you consider it out of the scope of the project.

It would be nice to have the program listen to the current default speaker output and visualize it.
Not sure how the Raylib integration with it is gonna be (the callback).
Or how easy is it to make it cross-platform.

division by 0 on tooltips

It is possible to end up with a difference value of 0 in the tooltip rendering code causing a division by zero. I have recorded a crash of dx being 0, causing a segfault.

    int dx = tooltip_boundary.x - diff.x;
    int dy = tooltip_boundary.y - diff.y;
    int dw = tooltip_boundary.width - diff.width;
    int dh = tooltip_boundary.height - diff.height;
    tooltip_boundary.x -= dx/abs(dx)*dw;
    tooltip_boundary.y -= dy/abs(dy)*dh;

FLAC Format is supported in raylib

Raylib supports the first six formats by default as you documented it, but support for FLAC isn’t included unless you compile it in yourself. If you want it, you’ll need a customised build with the SUPPORT_FILEFORMAT_FLAC flag turned on.

I have enabled FLAC support in config.h and recompiled raylib completely and now it is working.

INFO: AUDIO: Device initialized successfully
INFO:     > Backend:       miniaudio / PulseAudio
INFO:     > Format:        32-bit IEEE Floating Point -> 16-bit Signed Integer
INFO:     > Channels:      2 -> 2
INFO:     > Sample rate:   48000 -> 48000
INFO:     > Periods size:  3600
INFO: FILEIO: [./resources/fonts/Alegreya-Regular.ttf] File loaded successfully
INFO: TEXTURE: [ID 3] Texture loaded successfully (1024x512 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (64 pixel size | 95 glyphs)
INFO: TEXTURE: [ID 3] Mipmaps generated automatically, total: 11
INFO: FILEIO: [./resources/shaders/glsl330/circle.fs] Text file loaded successfully
INFO: SHADER: [ID 4] Fragment shader compiled successfully
INFO: SHADER: [ID 5] Program shader loaded successfully
INFO: TEXTURE: [ID 4] Texture loaded successfully (1600x900 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Depth renderbuffer loaded successfully (32 bits)
INFO: FBO: [ID 1] Framebuffer object created successfully
INFO: STREAM: Initialized successfully (44100 Hz, 16 bit, Stereo)
INFO: FILEIO: [/home/starapo7348/Music/05-mj-bit.flac] Music file loaded successfully
INFO:     > Sample rate:   44100 Hz
INFO:     > Sample size:   16 bits
INFO:     > Channels:      2 (Stereo)
INFO:     > Total frames:  11379564
INFO: FILEIO: [./resources/icons/fullscreen.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (2048x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 5] Texture loaded successfully (2048x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 5] Mipmaps generated automatically, total: 12
INFO: FILEIO: [./resources/icons/volume.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (1536x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 6] Texture loaded successfully (1536x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 6] Mipmaps generated automatically, total: 11
INFO: STREAM: Initialized successfully (48000 Hz, 24 bit, Stereo)
INFO: FILEIO: [/home/starapo7348/Music/15. 405.3 Thumb CAD.flac] Music file loaded successfully
INFO:     > Sample rate:   48000 Hz
INFO:     > Sample size:   24 bits
INFO:     > Channels:      2 (Stereo)
INFO:     > Total frames:  8981433
INFO: AUDIO: Device closed successfully
INFO: TEXTURE: [ID 2] Unloaded texture data from VRAM (GPU)
INFO: SHADER: [ID 3] Default shader unloaded successfully
INFO: TEXTURE: [ID 1] Default texture unloaded successfully
INFO: Window closed successfully

screenshot

I have found this info here:

gmusializer(20953,0x1e2b35b40) malloc: double free for ptr 0x158028000

Hi, I love all your YouTube videos and was watching your latest one This Release is Insane!, then I want to try it by myself. Here are the steps I had tried and then I saw the double free bug:

Apple M2 Macbook Air with the following clang version:

clang --version
Homebrew clang version 17.0.6
Target: arm64-apple-darwin22.4.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
  1. Install ffmpeg and raylib 5.0

  2. Compile the project

    # Compile no build without any error
    clang -o nob nob.c
    
    # Comiple the binary with warnings
    /Users/wison/c/musializer   ./nob
    
    # [INFO] --- STAGE 1 ---
    # [INFO] created directory `build`
    # [INFO] Generating ./build/config.h
    # [INFO] CMD: cc -o ./build/nob.configured nob.c -DCONFIGURED
    # [INFO] CMD: ./build/nob.configured
    # [INFO] --- STAGE 2 ---
    # [INFO] Target: macos
    # [INFO] Hotreload: DISABLED
    # [INFO] Microphone: DISABLED
    # [INFO] ---
    # [INFO] created directory `./build/raylib`
    # [INFO] created directory `./build/raylib/macos`
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/rcore.c -o ./build/raylib/macos/rcore.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/raudio.c -o ./build/raylib/macos/raudio.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -x objective-c -c ./raylib/raylib-5.0/src/rglfw.c -o ./build/raylib/macos/rglfw.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/rmodels.c -o ./build/raylib/macos/rmodels.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/rshapes.c -o ./build/raylib/macos/rshapes.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/rtext.c -o ./build/raylib/macos/rtext.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/rtextures.c -o ./build/raylib/macos/rtextures.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/utils.c -o ./build/raylib/macos/utils.o
    # In file included from ./raylib/raylib-5.0/src/rmodels.c:111:
    # ./raylib/raylib-5.0/src/external/par_shapes.h:1133:32: warning: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-const-int-float-conversion]
    #  1133 |     float r = (float) rand() / RAND_MAX;
    #       |                              ~ ^~~~~~~~
    # /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/stdlib.h:105:18: note: expanded from macro 'RAND_MAX'
    #   105 | #define RAND_MAX        0x7fffffff
    #       |                         ^~~~~~~~~~
    # 1 warning generated.
    # [INFO] CMD: ar -crs ./build/raylib/macos/libraylib.a ./build/raylib/macos/rcore.o ./build/raylib/macos/raudio.o ./build/raylib/macos/rglfw.o ./build/raylib/macos/rmodels.o ./build/raylib/macos/rshapes.o ./build/raylib/macos/rtext.o ./build/raylib/macos/rtextures.o ./build/raylib/macos/utils.o
    # [INFO] CMD: clang -Wall -Wextra -g -I./build/ -I./raylib/raylib-5.0/src/ -o ./build/musializer ./src/plug.c ./src/ffmpeg_linux.c ./src/musializer.c ./build/raylib/macos/libraylib.a -framework CoreVideo -framework IOKit -framework Cocoa -framework GLUT -framework OpenGL -lm -ldl -lpthread
    # [INFO] created directory `./build/resources/`
    # [INFO] created directory `./build/resources//logo`
    # [INFO] copying ./resources//logo/logo-256.ico -> ./build/resources//logo/logo-256.ico
    # [INFO] copying ./resources//logo/logo-256.png -> ./build/resources//logo/logo-256.png
    # [INFO] copying ./resources//logo/logo.svg -> ./build/resources//logo/logo.svg
    # [INFO] created directory `./build/resources//icons`
    # [INFO] copying ./resources//icons/fullscreen.svg -> ./build/resources//icons/fullscreen.svg
    # [INFO] copying ./resources//icons/volume.png -> ./build/resources//icons/volume.png
    # [INFO] copying ./resources//icons/volume.svg -> ./build/resources//icons/volume.svg
    # [INFO] copying ./resources//icons/fullscreen.png -> ./build/resources//icons/fullscreen.png
    # [INFO] created directory `./build/resources//shaders`
    # [INFO] created directory `./build/resources//shaders/glsl120`
    # [INFO] copying ./resources//shaders/glsl120/circle.fs -> ./build/resources//shaders/glsl120/circle.fs
    # [INFO] created directory `./build/resources//shaders/glsl330`
    # [INFO] copying ./resources//shaders/glsl330/circle.fs -> ./build/resources//shaders/glsl330/circle.fs
    # [INFO] created directory `./build/resources//fonts`
    # [INFO] copying ./resources//fonts/OFL.txt -> ./build/resources//fonts/OFL.txt
    # [INFO] copying ./resources//fonts/Alegreya-Regular.ttf -> ./build/resources//fonts/Alegreya-Regular.ttf
    
    
    ls -lht build/
    # total 5696
    # drwxr-xr-x@ 6 wison  staff   192B 22 Dec 09:50 resources/
    # drwxr-xr-x@ 3 wison  staff    96B 22 Dec 09:50 musializer.dSYM/
    # -rwxr-xr-x@ 1 wison  staff   2.7M 22 Dec 09:50 musializer*
    # drwxr-xr-x@ 3 wison  staff    96B 22 Dec 09:50 raylib/
    # -rwxr-xr-x@ 1 wison  staff    69K 22 Dec 09:50 nob.configured*
    # -rw-r--r--@ 1 wison  staff   457B 22 Dec 09:50 config.h
  3. Run it without error

    /Users/wison/c/musializer   ./build/musializer
    
    # INFO: FILEIO: [./resources/logo/logo-256.png] File loaded successfully
    # INFO: IMAGE: Data loaded successfully (256x256 | R8G8B8A8 | 1 mipmaps)
    # INFO: Initializing raylib 5.0
    # INFO: Platform backend: DESKTOP (GLFW)
    # INFO: Supported raylib modules:
    # INFO:     > rcore:..... loaded (mandatory)
    # INFO:     > rlgl:...... loaded (mandatory)
    # INFO:     > rshapes:... loaded (optional)
    # INFO:     > rtextures:. loaded (optional)
    # INFO:     > rtext:..... loaded (optional)
    # INFO:     > rmodels:... loaded (optional)
    # INFO:     > raudio:.... loaded (optional)
    # INFO: DISPLAY: Device initialized successfully
    # INFO:     > Display size: 1280 x 832
    # INFO:     > Screen size:  1280 x 720
    # INFO:     > Render size:  1280 x 720
    # INFO:     > Viewport offsets: 0, 0
    # INFO: GLAD: OpenGL extensions loaded successfully
    # INFO: GL: Supported extensions count: 43
    # INFO: GL: OpenGL device information:
    # INFO:     > Vendor:   Apple
    # INFO:     > Renderer: Apple M2
    # INFO:     > Version:  4.1 Metal - 83.1
    # INFO:     > GLSL:     4.10
    # INFO: GL: VAO extension detected, VAO functions loaded successfully
    # INFO: GL: NPOT textures extension detected, full NPOT textures supported
    # INFO: GL: DXT compressed textures supported
    # INFO: PLATFORM: DESKTOP (GLFW): Initialized successfully
    # INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
    # INFO: TEXTURE: [ID 1] Default texture loaded successfully
    # INFO: SHADER: [ID 1] Vertex shader compiled successfully
    # INFO: SHADER: [ID 2] Fragment shader compiled successfully
    # INFO: SHADER: [ID 3] Program shader loaded successfully
    # INFO: SHADER: [ID 3] Default shader loaded successfully
    # INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
    # INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
    # INFO: RLGL: Default OpenGL state initialized successfully
    # INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
    # INFO: FONT: Default font loaded successfully (224 glyphs)
    # WARNING: GLFW: Error: 65548 Description: Cocoa: Regular windows do not have icons on macOS
    # INFO: TIMER: Target time per frame: 16.667 milliseconds
    # INFO: AUDIO: Device initialized successfully
    # INFO:     > Backend:       miniaudio / Core Audio
    # INFO:     > Format:        32-bit IEEE Floating Point -> 32-bit IEEE Floating Point
    # INFO:     > Channels:      2 -> 2
    # INFO:     > Sample rate:   48000 -> 48000
    # INFO:     > Periods size:  1440
    # INFO: FILEIO: [./resources/fonts/Alegreya-Regular.ttf] File loaded successfully
    # INFO: TEXTURE: [ID 3] Texture loaded successfully (1024x512 | GRAY_ALPHA | 1 mipmaps)
    # INFO: FONT: Data loaded successfully (64 pixel size | 95 glyphs)
    # INFO: TEXTURE: [ID 3] Mipmaps generated automatically, total: 11
    # INFO: FILEIO: [./resources/shaders/glsl330/circle.fs] Text file loaded successfully
    # INFO: SHADER: [ID 4] Fragment shader compiled successfully
    # INFO: SHADER: [ID 5] Program shader loaded successfully
    # INFO: TEXTURE: [ID 4] Texture loaded successfully (1600x900 | R8G8B8A8 | 1 mipmaps)
    # INFO: TEXTURE: [ID 1] Depth renderbuffer loaded successfully (32 bits)
    # INFO: FBO: [ID 1] Framebuffer object created successfully
  4. Drag&drop 2 MP3 files into the UI, then it crash:

    running_screenshot
    gmusializer(20953,0x1e2b35b40) malloc: double free for ptr 0x158028000
    musializer(20953,0x1e2b35b40) malloc: *** set a breakpoint in malloc_error_break to debug
    fish: Job 1, './build/musializer' terminated by signal SIGABRT (Abort)

nob_win64_mingw.c executable name variance.

As my first experience with nob I tried building with Mingw64. I'm using the same version that came with Raylib installable setup.
I noticed that building stopped at compiling Raylib's *.os into an *.a and gave this error.

[INFO] CMD: x86_64-w64-mingw32-ar -crs ./build/raylib/win64-mingw/libraylib.a ./build/raylib/win64-mingw/rcore.o ./build/raylib/win64-mingw/raudio.o ./build/raylib/win64-mingw/rglfw.o ./build/raylib/win64-mingw/rmodels.o ./build/raylib/win64-mingw/rshapes.o ./build/raylib/win64-mingw/rtext.o ./build/raylib/win64-mingw/rtextures.o ./build/raylib/win64-mingw/utils.o
[ERROR] Could not create child process: 2

After checking content of my Mingw, I saw only x86_64-w64-mingw32-gcc-ar being the closest name.
Replaced here:

nob_cmd_append(&cmd, "x86_64-w64-mingw32-ar", "-crs", libraylib_path);

After that everything worked.
Dunno, maybe there's a way to check it's name?

[Build] nob build fails for macOS with "undeclared function 'kill'"

The latest additions cause the nob build to fail on macOS.

Since I noticed a TODO in the source about checking the build for macOS, I went ahead and did so, and can confirm that commit 070b88ce can build and run correctly on Darwin kernel 23.4.0 arm64.

Then, I checked the subsequent commit c8486721, and it seems to still build fine.

The first commit that breaks is 1d229d93.

This commit introduces this line:

if (cancel) kill(pid, SIGKILL);

The workflow fails with:

./src/ffmpeg_linux.c:102:17: error: call to undeclared function 'kill'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

From my searches, defining _POSIX_C_SOURCE as a high enough value should ensure this does not happen, and it needs to be defined before any other definition.

Alas, I haven't been able to fix it.

Maybe it should be passed as a definition to the compiler instead, if there is no clear path to defining it first. Or it may be a red herring.

Edit: it seems _POSIX_C_SOURCE is not needed, but including signal.h is required from clang or something...
I opened #111 to add the line.

I cannot build on Windows ...

... Probably because I am too stupid to work nob.exe, but here's what happens when I try:

Microsoft Windows [Version 10.0.19045.3930]
(c) Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>cd /d c:\users\DEVNVME\Desktop\musializer

c:\Users\DevNVME\Desktop\musializer>"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat" x86_amd64


** Visual Studio 2022 Developer Command Prompt v17.8.3
** Copyright (c) 2022 Microsoft Corporation


[vcvarsall.bat] Environment initialized for: 'x86_x64'

c:\Users\DevNVME\Desktop\musializer>cl.exe nob.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33133 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

nob.c
Microsoft (R) Incremental Linker Version 14.38.33133.0
Copyright (C) Microsoft Corporation. All rights reserved.

/out:nob.exe
nob.obj

c:\Users\DevNVME\Desktop\musializer>nob.exe
[INFO] --- STAGE 1 ---
[INFO] created directory build
[INFO] Generating ./build/config.h
[INFO] CMD: cl.exe nob.c -DCONFIGURED
Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33133 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

nob.c
Microsoft (R) Incremental Linker Version 14.38.33133.0
Copyright (C) Microsoft Corporation. All rights reserved.

/out:nob.exe
nob.obj
LINK : fatal error LNK1104: cannot open file 'nob.exe'
[ERROR] command exited with exit code 2

[Windows] Crash when connecting/disconnecting microphone

I just built the latest commit on this niche operating system for video games using MinGW to try the new microphone feature, because published release does not have it. Crashes even when microphone mode is disabled.

Despite that, works pretty fine.

EDIT:
Nothing in log about that

Couldn't render on ubuntu linux subsystem

When running musializer on Ubuntu in Windows it couldn't render the video because ffmpeg can't write into a ffmpeg pipe.
and when pressing ESC it glitch for a second

[macOS] No sound on Mac

Running macOS Sonoma 14.0 on a MacBook Air M1, graph works but no audio =/

Logs when compiling

./nob
[INFO] created directory `build`
[INFO] Saving configuration to ./build/build.conf
[INFO] ------------------------------
[INFO] Target: macos
[INFO] Hotreload: DISABLED
[INFO] Microphone: DISABLED
[INFO] ------------------------------
[INFO] created directory `./build/raylib`
[INFO] created directory `./build/raylib/macos`
[INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-4.5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-4.5.0/src/rcore.c -o ./build/raylib/macos/rcore.o
[INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-4.5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-4.5.0/src/raudio.c -o ./build/raylib/macos/raudio.o
[INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-4.5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -x objective-c -c ./raylib/raylib-4.5.0/src/rglfw.c -o ./build/raylib/macos/rglfw.o
[INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-4.5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-4.5.0/src/rmodels.c -o ./build/raylib/macos/rmodels.o
[INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-4.5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-4.5.0/src/rshapes.c -o ./build/raylib/macos/rshapes.o
[INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-4.5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-4.5.0/src/rtext.c -o ./build/raylib/macos/rtext.o
[INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-4.5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-4.5.0/src/rtextures.c -o ./build/raylib/macos/rtextures.o
[INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-4.5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-4.5.0/src/utils.c -o ./build/raylib/macos/utils.o
In file included from ./raylib/raylib-4.5.0/src/rmodels.c:112:
./raylib/raylib-4.5.0/src/external/par_shapes.h:1133:32: warning: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-const-int-float-conversion]
 1133 |     float r = (float) rand() / RAND_MAX;
      |                              ~ ^~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/stdlib.h:105:18: note: expanded from macro 'RAND_MAX'
  105 | #define RAND_MAX        0x7fffffff
      |                         ^~~~~~~~~~
./raylib/raylib-4.5.0/src/raudio.c:1297:45: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
 1297 |         qoaplay_desc *ctxQoa = qoaplay_open(fileName);
      |                                             ^~~~~~~~
./raylib/raylib-4.5.0/src/external/qoaplay.c:86:34: note: passing argument to parameter 'path' here
   86 | qoaplay_desc *qoaplay_open(char *path)
      |                                  ^
1 warning generated.
1 warning generated.
[INFO] CMD: ar -crs ./build/raylib/macos/libraylib.a ./build/raylib/macos/rcore.o ./build/raylib/macos/raudio.o ./build/raylib/macos/rglfw.o ./build/raylib/macos/rmodels.o ./build/raylib/macos/rshapes.o ./build/raylib/macos/rtext.o ./build/raylib/macos/rtextures.o ./build/raylib/macos/utils.o
[INFO] CMD: clang -Wall -Wextra -g -I./raylib/raylib-4.5.0/src/ -o ./build/musializer ./src/plug.c ./src/ffmpeg_linux.c ./src/musializer.c ./build/raylib/macos/libraylib.a -framework CoreVideo -framework IOKit -framework Cocoa -framework GLUT -framework OpenGL -lm -ldl -lpthread
[INFO] created directory `./build/resources/`
[INFO] created directory `./build/resources//logo`
[INFO] copying ./resources//logo/logo-256.ico -> ./build/resources//logo/logo-256.ico
[INFO] copying ./resources//logo/logo-256.png -> ./build/resources//logo/logo-256.png
[INFO] copying ./resources//logo/logo.svg -> ./build/resources//logo/logo.svg
[INFO] created directory `./build/resources//icons`
[INFO] copying ./resources//icons/fullscreen.svg -> ./build/resources//icons/fullscreen.svg
[INFO] copying ./resources//icons/volume.png -> ./build/resources//icons/volume.png
[INFO] copying ./resources//icons/volume.svg -> ./build/resources//icons/volume.svg
[INFO] copying ./resources//icons/fullscreen.png -> ./build/resources//icons/fullscreen.png
[INFO] created directory `./build/resources//shaders`
[INFO] created directory `./build/resources//shaders/glsl120`
[INFO] copying ./resources//shaders/glsl120/circle.fs -> ./build/resources//shaders/glsl120/circle.fs
[INFO] created directory `./build/resources//shaders/glsl330`
[INFO] copying ./resources//shaders/glsl330/circle.fs -> ./build/resources//shaders/glsl330/circle.fs
[INFO] created directory `./build/resources//fonts`
[INFO] copying ./resources//fonts/OFL.txt -> ./build/resources//fonts/OFL.txt
[INFO] copying ./resources//fonts/Alegreya-Regular.ttf -> ./build/resources//fonts/Alegreya-Regular.ttf

Logs when running

./build/musializer
INFO: FILEIO: [./resources/logo/logo-256.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (256x256 | R8G8B8A8 | 1 mipmaps)
INFO: Initializing raylib 4.5
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 1440 x 900
INFO:     > Screen size:  1280 x 720
INFO:     > Render size:  1280 x 720
INFO:     > Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: GL: Supported extensions count: 43
INFO: GL: OpenGL device information:
INFO:     > Vendor:   Apple
INFO:     > Renderer: Apple M1
INFO:     > Version:  4.1 Metal - 86
INFO:     > GLSL:     4.10
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: DXT compressed textures supported
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
WARNING: GLFW: Error: 65548 Description: Cocoa: Regular windows do not have icons on macOS
INFO: TIMER: Target time per frame: 16.667 milliseconds
INFO: AUDIO: Device initialized successfully
INFO:     > Backend:       miniaudio / Null
INFO:     > Format:        32-bit IEEE Floating Point -> 32-bit IEEE Floating Point
INFO:     > Channels:      2 -> 2
INFO:     > Sample rate:   48000 -> 48000
INFO:     > Periods size:  1440
INFO: FILEIO: [./resources/fonts/Alegreya-Regular.ttf] File loaded successfully
INFO: TEXTURE: [ID 3] Texture loaded successfully (1024x1024 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (64 pixel size | 95 glyphs)
INFO: TEXTURE: [ID 3] Mipmaps generated automatically, total: 11
INFO: FILEIO: [./resources/shaders/glsl330/circle.fs] Text file loaded successfully
INFO: SHADER: [ID 4] Fragment shader compiled successfully
INFO: SHADER: [ID 5] Program shader loaded successfully
INFO: SHADER: [ID 5] Shader attribute (vertexPosition) set at location: 0
INFO: SHADER: [ID 5] Shader attribute (vertexTexCoord) set at location: 1
WARNING: SHADER: [ID 5] Failed to find shader attribute: vertexTexCoord2
WARNING: SHADER: [ID 5] Failed to find shader attribute: vertexNormal
WARNING: SHADER: [ID 5] Failed to find shader attribute: vertexTangent
INFO: SHADER: [ID 5] Shader attribute (vertexColor) set at location: 3
INFO: SHADER: [ID 5] Shader uniform (mvp) set at location: 0
WARNING: SHADER: [ID 5] Failed to find shader uniform: matView
WARNING: SHADER: [ID 5] Failed to find shader uniform: matProjection
WARNING: SHADER: [ID 5] Failed to find shader uniform: matModel
WARNING: SHADER: [ID 5] Failed to find shader uniform: matNormal
WARNING: SHADER: [ID 5] Failed to find shader uniform: colDiffuse
WARNING: SHADER: [ID 5] Failed to find shader uniform: texture0
WARNING: SHADER: [ID 5] Failed to find shader uniform: texture1
WARNING: SHADER: [ID 5] Failed to find shader uniform: texture2
INFO: SHADER: [ID 5] Shader uniform (radius) set at location: 4
INFO: SHADER: [ID 5] Shader uniform (power) set at location: 5
INFO: TEXTURE: [ID 4] Texture loaded successfully (1600x900 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Depth renderbuffer loaded successfully (32 bits)
INFO: FBO: [ID 1] Framebuffer object created successfully
INFO: STREAM: Initialized successfully (44100 Hz, 16 bit, Stereo)
INFO: FILEIO: [/Users/ihavenoideawhatimdoing/Movies/nu11 wip works 2016-2022 (ogg)/fading away (2022)/fading away.ogg] Music file loaded successfully
INFO:     > Sample rate:   44100 Hz
INFO:     > Sample size:   16 bits
INFO:     > Channels:      2 (Stereo)
INFO:     > Total frames:  3466969
INFO: FILEIO: [./resources/icons/fullscreen.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (2048x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 5] Texture loaded successfully (2048x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 5] Mipmaps generated automatically, total: 12
INFO: FILEIO: [./resources/icons/volume.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (1536x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 6] Texture loaded successfully (1536x512 | GRAY_ALPHA | 1 mipmaps)
INFO: TEXTURE: [ID 6] Mipmaps generated automatically, total: 11

Funny thing: When I render a video the output.mp4 has audio (yeah... ffmpeg 6.0_1 is working), when I run the songs from musializar binary I have no sound :/

[nob] Minimize uses of defines for some multiline defines/functions

General whinning

One of my biggest qualms(issue) with the original nobuild was the use of defines for code that is essentially a function.

Why ? Well in C, debuggability is a major plus in the language, and functions that are implemented as defines remove this feature from the language. Some defines make sense but not for all multiline code imo.

Maybe you have a logical reason for using a lot of defines(generally), sadly my ugabooga software developer brain doesn't know it or can't deduce it.

The offending funcs

The main functions that should be functions imho are

nob_da_append
nob_da_append_many

Reasoning

These functions are used in a bunch a defines so if at it least these functions would not be defines users could debug and find out how they shot themselves in the foot.

Thanks for your work on this btw. Really cool project !

is Raylib did not better option for Musializer.

The games use 99% of CPU and it's normal, but if Musializer or another powerful tool acts as a game and uses 10% of CPU when we use 60 or 120 FPS is terrible, so we can't use any Raylib app in daily life, including Musializer, no one wants to use such an app that eats the resources and battery quickly.

I asked Raysan about this problem, he mentioned that the solution is to remove the SetTargetFPS() and hack the EndDrawing(), what's your opinion, could Musializer be optimized for CPU and battery 🔋 life.

GLFW: Error: 65543 Description: GLX: Failed to create context: GLXBadFBConfig

adminq@q4os-desktop:~/Downloads/musializer$ ./build/musializer
INFO: FILEIO: [./resources/logo/logo-256.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (256x256 | R8G8B8A8 | 1 mipmaps)
INFO: Initializing raylib 4.6-dev
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
INFO: DISPLAY: Trying to enable MSAA x4
WARNING: GLFW: Error: 65543 Description: GLX: Failed to create context: GLXBadFBConfig
WARNING: GLFW: Failed to initialize Window
FATAL: Failed to initialize Graphic Device

Other GLFW apps seem to work fine (tried goxel).
Q4OS 5.2 (Debian 12) VirtualBox VM 32bit

[Feature] Kind of a playlist mode?

Currently Musializer will loop the same track endlessly.
If there are multiple tracks, imo it would be better to play the next track after the current one finished playing. When the last track in the track list finishes, go back to the first one.
This would be similiar to how most music players implement playlists, thus the title.

Add option for user to define their own CFLAGS and CC

CFLAGS

I didn't want to make a PR since I don't know how you would prefer to implement this.
If you're fine with this in nob.c and handling it in every src/nob_*.c file then I'd be happy to make a PR.

#define CFLAGS "-O3", "-march=native"

I don't know however what flags msvc accepts, I do not own a windows device, and having a define sort of implies needing a set of default CFLAGS i.e -O0 -ggdb or something.

Another option is defining it in build/config.h but that sort of requires you to run nob once to generate the config.h if you don't know what should be in there.

Either way, this feature would be pretty useful since package managers like emerge and makepkg want to pass CFLAGS to build scripts.

CC

On windows, it is also possible to use clang, and if someone wants to cross-compile musializer, passing a cross-compilation gcc on linux would be useful

Program Stops When Minimized

OS: Arch Linux
Kernel: 6.6.11-1-lts
DE: Plasma 5.27.10
Display Server: X11

Issue

The whole program stops, both visuals and audio, when minimized and resumes when restored.
Demonstration

Cannot load file

When music file name contains language specific characters (non ascii), app shows that it could not load file.
Example chars: ł, ą, ó, ś, ć

Build succeed on macOS. No audio, Visualizing works perfectly. [Fixed]

  • I am using a macOS Apple Silicon.
  • The build works just fine. ./nob config && ./nob build (Although i am getting some warning that in nob.c the switch case doesn't handle macOS, maybe that's the cause of the issue)
  • The audio doesn't work. no music is playing. although the visualization is perfect.

nob build fails on windows when called without file extension

Running nob without .exe file extension fails.

w:\musializer>nob build
[INFO] renaming nob -> nob.old
[ERROR] could not rename nob to nob.old: 2

The application takes its name from argv[0] which is nob and tries to rename a file name nob that does not exist. (Hint: The file name is nob.exe)

The build system should append the appropriate file extension to support being called without .exe.

One way to achieve this functionality would be:

    char pathbuf[MAX_PATH];
    GetModuleFileNameA(NULL, pathbuf, MAX_PATH);

To retrieve the binary path instead of using argv[0].

I think one should consider what should happen when the executable is called with a relative path.

w:\musializer>cd build
w:\musializer\build>..\nob.exe
[ERROR] Could not open file nob.c: 2

I think the build system could assume that nob.exe and nob.c are always in the same directory. To support calling the build system from a different working directory, the directory the binary lives in should be prepended to the file name of the source file to generate the full source file path.

[NOB] Nob_Cmd not null-terminated

All the commands are never explicitly null-terminated, which is expected by execvp and CreateProcess.
They are only by accident, because realloc gives zero initialized memory most of the time, even thought the spec says it's uninitialized.

You can replace nob_da_append with

#define nob_da_append(da, item)                                                          \
    do {                                                                                 \
        if ((da)->count >= (da)->capacity) {                                             \
            (da)->capacity = (da)->capacity == 0 ? NOB_DA_INIT_CAP : (da)->capacity*2;   \
            (da)->items = NOB_REALLOC((da)->items, (da)->capacity*sizeof(*(da)->items)); \
            NOB_ASSERT((da)->items != NULL && "Buy more RAM lol");                       \
        }                                                                                \
                                                                                         \
        (da)->items[(da)->count++] = (item);                                             \
        *(unsigned char *) ((da)->items + (da)->count) = 0xDE;                           \
    } while (0)

to force a non zero byte after the last element.

Maybe check for an empty or non null-terminated command:

diff --git a/nob.h b/nob.h
index d5bf4fb..466d966 100644
--- a/nob.h
+++ b/nob.h
@@ -489,6 +489,16 @@ void nob_cmd_append_null(Nob_Cmd *cmd, ...)
 
 Nob_Proc nob_cmd_run_async(Nob_Cmd cmd)
 {
+    if (cmd.count == 0) {
+        nob_log(NOB_ERROR, "There is no point in running an empty command.");
+        return NOB_INVALID_PROC;
+    }
+
+    if (cmd.items[cmd.count - 1] != 0) {
+        nob_log(NOB_ERROR, "The command array needs to be null-terminated.");
+        return NOB_INVALID_PROC;
+    }
+
     Nob_String_Builder sb = {0};
     nob_cmd_render(cmd, &sb);
     nob_sb_append_null(&sb);

[windows] shellapi.h(68): error C2061: syntax errors

Ran into the [ERROR] Could not open file nob.c: 2 error. Running nob.exe did work.

I am now at something with my shellapi.
I see there is some concern with getting windows.h included before shellapi. I verified the code and see windows.h being included; and I also tested by adding it into plug.c. This did not work.

[INFO] CMD: cl.exe /I ./raylib/raylib-4.5.0/src/ /Fobuild\ /Febuild\musializer.exe ./src/musializer.c ./src/plug.c ./src/ffmpeg_windows.c /link /LIBPATH:build/raylib/win64-msvc raylib.lib Winmm.lib gdi32.lib User32.lib Shell32.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.37.32824 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

musializer.c
plug.c
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(68): error C2061: syntax error: identifier 'DECLSPEC_IMPORT'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(68): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(68): error C2143: syntax error: missing '{' before '*'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(68): error C2061: syntax error: identifier 'CommandLineToArgvW'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(68): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(68): error C2146: syntax error: missing ')' before identifier 'lpCmdLine'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(68): error C2061: syntax error: identifier 'lpCmdLine'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(68): error C2059: syntax error: ','
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(68): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(82): error C2061: syntax error: identifier 'DECLSPEC_IMPORT'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(82): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(82): error C2061: syntax error: identifier 'STDAPICALLTYPE'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(82): error C2146: syntax error: missing ')' before identifier 'hDrop'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(82): error C2061: syntax error: identifier 'hDrop'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(82): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(82): error C2059: syntax error: ','
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(82): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(84): error C2061: syntax error: identifier 'DECLSPEC_IMPORT'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(84): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(84): error C2061: syntax error: identifier 'STDAPICALLTYPE'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(84): error C2146: syntax error: missing ')' before identifier 'hDrop'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(84): error C2061: syntax error: identifier 'hDrop'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(84): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(84): error C2059: syntax error: ','
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(84): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(90): error C2061: syntax error: identifier 'DECLSPEC_IMPORT'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(90): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(90): error C2061: syntax error: identifier 'STDAPICALLTYPE'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(90): error C2146: syntax error: missing ')' before identifier 'hDrop'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(90): error C2061: syntax error: identifier 'hDrop'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(90): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(90): error C2059: syntax error: ','
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(90): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(91): error C2061: syntax error: identifier 'DECLSPEC_IMPORT'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(91): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(91): error C2061: syntax error: identifier 'DragFinish'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(91): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(91): error C2146: syntax error: missing ')' before identifier 'hDrop'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(91): error C2061: syntax error: identifier 'hDrop'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(91): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(92): error C2061: syntax error: identifier 'DECLSPEC_IMPORT'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(92): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(92): error C2061: syntax error: identifier 'DragAcceptFiles'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(92): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(92): error C2146: syntax error: missing ')' before identifier 'hWnd'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(92): error C2061: syntax error: identifier 'hWnd'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(92): error C2059: syntax error: ','
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(92): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(94): error C2061: syntax error: identifier 'DECLSPEC_IMPORT'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(94): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(94): error C2061: syntax error: identifier 'STDAPICALLTYPE'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(94): error C2146: syntax error: missing ')' before identifier 'hwnd'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(94): error C2061: syntax error: identifier 'hwnd'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(94): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(94): error C2059: syntax error: ','
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(95): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(96): error C2061: syntax error: identifier 'DECLSPEC_IMPORT'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(96): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(96): error C2061: syntax error: identifier 'STDAPICALLTYPE'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(96): error C2146: syntax error: missing ')' before identifier 'hwnd'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(96): error C2061: syntax error: identifier 'hwnd'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(96): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(96): error C2059: syntax error: ','
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(97): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(104): error C2061: syntax error: identifier 'DECLSPEC_IMPORT'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(104): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(104): error C2061: syntax error: identifier 'STDAPICALLTYPE'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(104): error C2146: syntax error: missing ')' before identifier 'lpFile'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(104): error C2061: syntax error: identifier 'lpFile'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(104): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(104): error C2059: syntax error: ','
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(104): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(106): error C2061: syntax error: identifier 'DECLSPEC_IMPORT'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(106): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(106): error C2061: syntax error: identifier 'STDAPICALLTYPE'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(106): error C2146: syntax error: missing ')' before identifier 'lpFile'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(106): error C2061: syntax error: identifier 'lpFile'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(106): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(106): error C2059: syntax error: ','
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(106): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(113): error C2061: syntax error: identifier 'DECLSPEC_IMPORT'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(113): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(113): error C2061: syntax error: identifier 'STDAPICALLTYPE'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(113): error C2146: syntax error: missing ')' before identifier 'hWnd'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(113): error C2061: syntax error: identifier 'hWnd'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(113): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(113): error C2059: syntax error: ','
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(113): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(114): error C2061: syntax error: identifier 'DECLSPEC_IMPORT'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(114): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(114): error C2061: syntax error: identifier 'STDAPICALLTYPE'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(114): error C2146: syntax error: missing ')' before identifier 'hWnd'
C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\shellapi.h(114): fatal error C1003: error count exceeds 100; stopping compilation
ffmpeg_windows.c
./src/ffmpeg_windows.c(79): warning C4047: 'initializing': 'FFMPEG *' differs in levels of indirection from 'int'
Generating Code...
[ERROR] command exited with exit code 2

https://stackoverflow.com/questions/2953704/vs2010-lots-of-errors-when-including-standard-libraries

[Windows] Music and video stops when moving the window

Description:

When you drag the window around the music and the video stops playing until you release it, then the video reset and the bars raise from the bottom.


Steps to reproduce:

  • Start Musializer
  • Play a song
  • Drag the window arround
  • Release the window

Expected behavior:

Music keeps playing and video doesn't stop.

Current behavior:

Music and video freez.

Versions:

  • Windows: Windows 10 Pro 22H2 (19045.3324)
  • Musializer: alpha1

Note:

I don't know if it's a bug or a feature, I didn't watch all the streams!

Race condition in Microphone capture

In start_capture, you initialize capturing. You do this by setting p->capturing = true, and then initializing the WAV writer.

musializer/src/plug.c

Lines 1260 to 1270 in 9ddb4d2

p->capturing = true;
const char *recording_file_path = "recording.wav";
drwav_data_format format = {0};
format.container = drwav_container_riff;
format.format = DR_WAVE_FORMAT_IEEE_FLOAT;
format.channels = 2;
format.sampleRate = 44100;
format.bitsPerSample = 32;
if (!drwav_init_file_write(&p->wav, recording_file_path, &format, NULL)) {

However, in the callback, you simply use the WAV writer as soon as p->capturing is true. Meaning that you might be using an uninitialized WAV (Note that this exact thing happened in the last stream, though the code looked a little different, when you tried to use a debugger).

musializer/src/plug.c

Lines 487 to 491 in 9ddb4d2

if (p->capturing) {
// TODO: according to documentation drwav_write_pcm_frames may not write all the frames.
// Make sure it does.
drwav_write_pcm_frames(&p->wav, frames, bufferData);
}

Windows port

is there any windows port or anyway to build this on windows ?

Build issue: Make readdir, closedir, opendir static in nob.h

raylib.lib(rcore.obj) : error LNK2005: opendir already defined in plug.obj
raylib.lib(rcore.obj) : error LNK2005: closedir already defined in plug.obj
raylib.lib(rcore.obj) : error LNK2005: readdir already defined in plug.obj

Both rcore.c and plug.c (via nob.h) export opendir, closedir and readdir. This results in a linker error. I fixed it currently by declaring them static in nob.h.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.