Giter Site home page Giter Site logo

orhun / linuxwave Goto Github PK

View Code? Open in Web Editor NEW
480.0 5.0 12.0 526 KB

Generate music from the entropy of Linux 🐧🎡

Home Page: http://orhun.dev/linuxwave/

License: MIT License

Zig 83.05% Dockerfile 1.54% Shell 3.93% HTML 11.47%
entropy linux music music-generation music-generator random random-music retrowave synthwave tune-generator

linuxwave's Introduction

linuxwave 🐧🎡

demo GitHub Release Coverage Continuous Integration Continuous Deployment Docker Builds Documentation

Click here to watch the demo!
Listen to "linuxwave" on Spotify!

Table of Contents

Motivation ✨

Installation πŸ€–

Build from source

Prerequisites

Instructions

  1. Clone the repository.
git clone https://github.com/orhun/linuxwave && cd linuxwave/
  1. Update git submodules.
git submodule update --init --recursive
  1. Build.
zig build -Drelease-safe

Binary will be located at zig-out/bin/linuxwave. You can also run the binary directly via zig build run.

If you want to use linuxwave in your Zig project as a package, the API documentation is available here.

Binary releases

See the available binaries for different targets from the releases page. They are automated via Continuous Deployment workflow.

Release tarballs are signed with the following PGP key: 0xC0701E98290D90B8

Arch Linux

linuxwave can be installed from the community repository using pacman:

pacman -S linuxwave

Void Linux

linuxwave can be installed from official Void Linux package repository:

xbps-install linuxwave

Docker

Images

Docker builds are automated and images are available in the following registries:

Usage

The following command can be used to generate output.wav in the current working directory:

docker run --rm -v "$(pwd)":/app "orhunp/linuxwave:${TAG:-latest}"

Building

Custom Docker images can be built from the Dockerfile:

docker build -t linuxwave .

Examples 🎡

Default: Read random data from /dev/urandom to generate a 20-second music composition in the A4 scale and save it to output.wav:

linuxwave

Or play it directly with mpv without saving:

linuxwave -o - | mpv -

To use the A minor blues scale:

linuxwave -s 0,3,5,6,7,10 -n 220 -o blues.wav

Read from an arbitrary file and turn it into a 10-second music composition in the C major scale:

linuxwave -i build.zig -n 261.63 -d 10 -o music.wav

Read from stdin via giving - as input:

cat README.md | linuxwave -i -

Write to stdout via giving - as output:

linuxwave -o - > output.wav

Presets 🎹

Generate a calming music with a sample rate of 2000 Hz and a 32-bit little-endian signed integer format:

linuxwave -r 2000 -f S32_LE -o calm.wav

Generate a chiptune music with a sample rate of 44100 Hz, stereo (2-channel) output and 8-bit unsigned integer format:

linuxwave -r 44100 -f U8 -c 2 -o chiptune.wav

Generate a boss stage music with the volume of 65:

linuxwave -s 0,7,1 -n 60 -v 65 -o boss.wav

Generate a spooky low-fidelity music with a sample rate of 1000 Hz, 4-channel output:

linuxwave -s 0,1,5,3 -n 100 -r 1000 -v 55 -c 4 -o spooky_manor.wav

Feel free to submit a pull request to show off your preset here!

Also, see this discussion for browsing the music generated by our community.

Usage πŸ“š

Options:
  -s, --scale <SCALE>            Sets the musical scale [default: 0,2,3,5,7,8,10,12]
  -n, --note <HZ>                Sets the frequency of the note [default: 440 (A4)]
  -r, --rate <HZ>                Sets the sample rate [default: 24000]
  -c, --channels <NUM>           Sets the number of channels [default: 1]
  -f, --format <FORMAT>          Sets the sample format [default: S16_LE]
  -v, --volume <VOL>             Sets the volume (0-100) [default: 50]
  -d, --duration <SECS>          Sets the duration [default: 20]
  -i, --input <FILE>             Sets the input file [default: /dev/urandom]
  -o, --output <FILE>            Sets the output file [default: output.wav]
  -V, --version                  Display version information.
  -h, --help                     Display this help and exit.

scale

Sets the musical scale for the output. It takes a list of semitones separated by commas as its argument.

The default value is 0,2,3,5,7,8,10,12, which represents a major scale starting from C.

Here are other examples:

  • A natural minor scale: 0,2,3,5,7,8,10
  • A pentatonic scale starting from G: 7,9,10,12,14
  • A blues scale starting from D: 2,3,4,6,7,10
  • An octatonic scale starting from F#: 6,7,9,10,12,13,15,16
  • Ryukyuan (Okinawa) Japanese scale: 4,5,7,11

note

The note option sets the frequency of the note played. It takes a frequency in Hz as its argument.

The default value is 440, which represents A4. You can see the frequencies of musical notes here.

Other examples would be:

  • A3 (220 Hz)
  • C4 (261.63 Hz)
  • G4 (392 Hz)
  • A4 (440 Hz) (default)
  • E5 (659.26 Hz)

rate

Sets the sample rate for the output in Hertz (Hz).

The default value is 24000.

channels

Sets the number of audio channels in the output file. It takes an integer as its argument, representing the number of audio channels to generate. The default value is 1, indicating mono audio.

For stereo audio, set the value to 2. For multi-channel audio, specify the desired number of channels.

Note that the more audio channels you use, the larger the resulting file size will be.

format

Sets the sample format for the output file. It takes a string representation of the format as its argument.

The default value is S16_LE, which represents 16-bit little-endian signed integer.

Possible values are:

  • U8: Unsigned 8-bit.
  • S16_LE: Signed 16-bit little-endian.
  • S24_LE: Signed 24-bit little-endian.
  • S32_LE: Signed 32-bit little-endian.

volume

Sets the volume of the output file as a percentage from 0 to 100.

The default value is 50.

duration

Sets the duration of the output file in seconds. It takes a float as its argument.

The default value is 20 seconds.

input

Sets the input file for the music generation. It takes a filename as its argument.

The default value is /dev/urandom, which generates random data.

You can provide any type of file for this argument and it will generate music based on the contents of that file.

output

Sets the output file. It takes a filename as its argument.

The default value is output.wav.

Funding πŸ’–

If you find linuxwave and/or other projects on my GitHub profile useful, consider supporting me on GitHub Sponsors or becoming a patron!

Support me on GitHub Sponsors Support me on Patreon Support me on Patreon

Contributing 🌱

See our Contribution Guide and please follow the Code of Conduct in all your interactions with the project.

License βš–οΈ

Licensed under The MIT License.

Copyright ⛓️

Copyright Β© 2023, Orhun ParmaksΔ±z

linuxwave's People

Contributors

bors[bot] avatar dependabot[bot] avatar orhun avatar tranzystorekk 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

linuxwave's Issues

FileNotFound error when building from source

Describe the bug

When I attempt to build from source following the instructions, I get the error: "FileNotFound: /home/tkk/temp/linuxwave/libs/zig-clap/clap.zig"

To reproduce

git clone https://github.com/orhun/linuxwave && cd linuxwave/ zig build -Drelease-safe

Expected behavior

The project should build with no errors

Screenshots / Logs
❯ zig build -Drelease-safe
warning: FileNotFound: /home/tkk/temp/linuxwave/libs/zig-clap/clap.zig
error: FileNotFound
error: linuxwave...
error: The following command exited with error code 1:
/usr/bin/zig build-exe /home/tkk/temp/linuxwave/src/main.zig -OReleaseSafe --cache-dir /home/tkk/temp/linuxwave/zig-cache --global-cache-dir /home/tkk/.cache/zig --name linuxwave --pkg-begin clap /home/tkk/temp/linuxwave/libs/zig-clap/clap.zig --pkg-end --pkg-begin file /home/tkk/temp/linuxwave/src/file.zig --pkg-end --pkg-begin gen /home/tkk/temp/linuxwave/src/gen.zig --pkg-end --pkg-begin wav /home/tkk/temp/linuxwave/src/wav.zig --pkg-end --pkg-begin build_options /home/tkk/temp/linuxwave/zig-cache/options/qMakyD73vBhS-mLFzE_KDtVFe5JLMb8_fa1uQfpzXJ_ZwUp24BkeEUgj8oneTF4J --pkg-end -fPIE --enable-cache
error: the following build command failed with exit code 1:
/home/tkk/temp/linuxwave/zig-cache/o/8205680e369cdd724044e5a08320985a/build /usr/bin/zig /home/tkk/temp/linuxwave /home/tkk/temp/linuxwave/zig-cache /home/tkk/.cache/zig -Drelease-safe

Software information

  • Operating system: Arch Linux 6.2.11-arch1-1
  • Zig version: 0.10.1
  • Project version: ?

P.S. This is my first bug report on GitHub. I don't quite know how to get Markdown to work properly

Reverb/echo

Is your feature request related to a problem? Please describe.

I am not a digital audio person at all so I don't know if this is easy or near-impossible, but I would love if this also had some setting for reverb or echo.

Describe the solution you'd like

Reverb or echo settings (to start to approach that 80s synthpad kind of feel)

Describe alternatives you've considered

Post processing with... something?

Additional context

Integrate a package manager

Is your feature request related to a problem? Please describe.

Currently, linuxwave is not packaged for any Zig package manager and the dependencies are simply git submodules.

Describe the solution you'd like

It would be nice to utilize zigmod and/or gyro.

Describe alternatives you've considered

None.

Additional context

See zerve project's files (gyro.zzz, zig.mod) which sparked this idea.

Note pitch and duration depends on sample rate

Describe the bug

It sounds bad at high sample rates.

To reproduce

linuxwave -r 192000 -c 2

Expected behavior

Pitches and durations should not depend on sample rate.

Software information

Arch Linux
linuxwave 0.1.0-1

Build Failing

Greetings! I recently came across your project and I'm very much looking forward to testing it out. However the build is failing.

Repoository was cloned, submodules were updated. Zig is version 0.11.0.

To reproduce:
zig build -Drelease-safe

Zig returns the following error:

/home/user/Tools/sound-tools/linuxwave/build.zig:30:19: error: no field or member function named 'standardReleaseOptions' in 'Build'
    const mode = b.standardReleaseOptions();
                 ~^~~~~~~~~~~~~~~~~~~~~~~
/snap/zig/8241/lib/std/Build.zig:1:1: note: struct declared here
const std = @import("std.zig");
^~~~~
referenced by:
    runBuild__anon_7127: /snap/zig/8241/lib/std/Build.zig:1639:37
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

System: Linux Mint 20.3 Una

Any tips would be helpful.
Thanks!

Permission denied when running the docker command

Describe the bug

Permission issue when running with the rootless docker or podman.

To reproduce

  1. Have rootless podman configured
  2. Run the following command
podman run --rm -it -v "$(pwd)":/app "orhunp/linuxwave:${TAG:-latest}"

You'll get the error

Reading 96 bytes from /dev/urandom
Saving to output.wav
Error occurred: error.AccessDenied

Expected behavior

Having output.wav in the current directory

Software information

  • OS: Arch linux
  • Rootless podman

Additional context

Solution
Remove those lines from the Dockerfile

chown 1000:1000 output.wav
USER 1000:1000

Note
You can remove -it option for docker or podman, it's not needed

Nice tool, GJ πŸ’―

MIDI support

Is your feature request related to a problem? Please describe.

Generating MIDI files from the input would be nice.

Describe the solution you'd like

Implement encoding MIDI files and add an option for selecting between WAV and MIDI.

e.g. linuxwave --output-format midi or linuxwave --midi

Describe alternatives you've considered

None.

Additional context

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.