Procedural engine sound generator controlled via GUI or CLI

Overview

enginesound

GUI Application used to generate purely synthetic engine sounds with advanced options written in Rust

loosely based on this paper

Reading the paper is highly recommended to understand the parameters

Features

General

  • Variable engine parameters
  • Mono WAV recording
  • RON SerDe of engine parameters
  • Pseudorealistic acoustic pipe/chamber simulation (speed of sound, pipe end reflection) based on the above paper
  • Advanced clap-rs powered CLI
  • Intake, Exhaust and Engine vibrations mixing
  • Resonance dampening (can save your audio equipment and ears)

GUI specific

  • Compilation of the GUI is enabled by default ("gui" feature, use --no-default-features to disable)
  • GUI made with conrod/glium
  • Real-time preview of parameters with cpal audio streaming
  • Real-time interactive parameter sliders with small descriptions
  • Record/Stop button
  • Dropping a config into the window loads the config
  • Save button to save the current parameters into a timestamped file in the current working directory
  • Reset sampler button to kill resonances in all acoustic chambers

CLI specific

  • Headless mode which does not start audio streaming or a GUI
  • Config argument to specify the file containing RON-serialized parameters
  • Volume/rpm/length arguments to control master volume/engine rpm/recording length
  • Crossfade argument which cuts the recording in half, swaps the halves and crossfades the middle x seconds (reduces output length by x/2 seconds), used to make seamless loops
  • Warmup time argument to wait for the resonances in the acoustic chambers to be established before recording

Preview

CLI

Engine Sound Generator 1.3.0
https://github.com/DasEtwas/
GUI Application used to generate purely synthetic engine sounds with advanced options in real-time, written in Rust.
It features real-time recording of the engine, a CLI, automatic crossfading to create seamless loops in the CLI,
realtime frequency domain display through FFT, and preset saving/loading capabilities.

USAGE:
    enginesound [FLAGS] [OPTIONS]

FLAGS:
        --help        Prints help information
    -h, --headless    CLI mode without GUI or audio playback
    -V, --version     Prints version information

OPTIONS:
    -c, --config <config>              Sets the input file to load as an engine config
    -f, --crossfade <crossfade>        Crossfades the recording in the middle end-to-start to create a seamless loop,
                                       although adjusting the recording's length to the rpm is recommended. The value
                                       sets the size of the crossfade, where the final output is decreased in length by
                                       crossfade_time/2.
    -o, --output <output_file>         Sets the output .wav file path
    -l, --length <reclen>              Sets the time to record in seconds. The formula for the recommended time to
                                       record to get a seamless loop is as follows:
                                       let wavelength = 120.0 / rpm;
                                       let crossfade = wavelength * 2.0;
                                       let reclen = audio_length + crossfade / 2.0;
    -r, --rpm <rpm>                    Engine RPM
    -q, --samplerate <samplerate>      Generator sample rate [default: 48000]
    -v, --volume <volume>              Sets the master volume [default: 0.1]
    -w, --warmup_time <warmup_time>    Sets the time to wait in seconds before recording

GUI

Image

Sound

Generated using the config shown above while adjusting the RPM manually: Audio file

Example pseudocode for generating a seamless loop

rpm = 1300
wavelength = 120 / rpm
average_len = 3.2                             // seconds
cycles = ceil(average_len / wavelength)
crossfade = 2 * wavelength
length = wavelength * cycles + crossfade / 2
warmup = 2                                    // seconds
fade_length = crossfade
volume = 0.5                                  // 50%

enginesound.exe -h -c config_file.esc -o output_file.wav -f $fade_length -l $length -w $warmup -r $rpm -v $volume

Licensing

MIT License

Comments
  • Understanding the algorithm

    Understanding the algorithm

    Hey!

    Your implementation is really impressive! I was reading the paper and I am trying to implement my own version in Matlab/c++. I was going through your initial commit and had trouble understanding how you established the relation between the variable x and the rpm. So I wanted to ask if you used any other sources besides the paper to write the code ? I am new to rust so its difficult to understand the flow.

    opened by ashwinb-git 22
  • No GUI when running on Windows 10

    No GUI when running on Windows 10

    I've build and run the software, but there is no GUI, no audio file is generated, and I've got the message below.

    C:\Users\marco\Desktop\enginesound-1.5.2\target\debug>enginesound
    Headless builds do not supply GUI
    Audio driver: Wasapi
    Samplerate: 48000 Hz
    Audio output device: Headphones (Logitech X300 Stereo)
    Audio output format: StreamConfig { channels: 2, sample_rate: SampleRate(48000), buffer_size: Default }
    thread '<unnamed>' panicked at 'Failed to build audio output stream: StreamConfigNotSupported', src\audio.rs:73:14
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any', src\audio.rs:102:6
    
    opened by Saitodepaula 8
  • How can I incorporate this in a c++ or python application?

    How can I incorporate this in a c++ or python application?

    Hi

    I like this development very much.

    Could you please help me, how can I incorporate this with a c++ or python application. Where I can on-the-fly play with volume and other parameters, when the audio play is live. By the way, having a GUI may not be mandatory in this case.

    Thanks

    opened by JeyP4 4
  • Not working on macOS

    Not working on macOS

    Hello,

    really cool project! Unfortunately, I can not get it running on macOS because there are some issues with glium when executing the compiled binary:

    Audio driver: CoreAudio
    Samplerate: 48000 Hz
    Audio output device: [My output device]
    Audio output format: F32
    thread 'main' panicked at 'assertion failed: backend.is_current()', /Users/username/.cargo/registry/src/github.com-1ecc6299db9ec823/glium-0.23.0/src/context/mod.rs:647:17
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    

    The error has already been reported on glium GitHub in the past and fixed in glium v0.24.0. When changing the version in the Cargo.toml I get some compile errors due to API changes which I'm unable to fix because I'm not familiar with Rust.

    Building with the --no-default-features flag doesn't work because rustc then complains about use of glium in the code.

    Do you know of a solution? Would it be hard to update to v0.24.0 of glium?

    Thanks in advance!

    opened by shilch 3
  • Getting an error in the GUI script

    Getting an error in the GUI script

    Hi There Just installed Rust and built your program which went just fine, no errors and the exe was built but when I run it I hear a brief bit of engine sound and a window pops up but then close instantly and I get the error:

    'thread 'main' panicked at 'index out of bounds: the len is 1024 but the index is 18446744073709551614', src\gui.rs:165:21 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace error: process didn't exit successfully: target\debug\enginesound.exe (exit code: 101)`

    Have I done something wrong or is there an issue. If I run in headless mode then a wav file is generated, but I would like to have the GUI working. Chris

    opened by spookycat 3
  • Cargo run/build on Windows 10 fail

    Cargo run/build on Windows 10 fail

    Hi, I'm totally new to Rust (the first contact I'm having with the language is to try to use this sofware), and I'm no professional in anything related to programming, so maybe I'm doing some obvious mistake here.

    On Windows 10 64 bit, I've downloaded Rust, installed, downloaded Build Tools for Visual Studio 2019, and, using rustup, I've updated Rust to the nightly build.

    When I type Cargo Run or Cargo Build in the directory I've unziped the 1.5.1 files, I've got the folowing:

    error[E0658]: attributes on expressions are experimental
       --> src\main.rs:206:17
        |
    206 |                 #[cfg(target_os = "windows")]
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
        = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
    
    error: removing an expression is not supported in this position
       --> src\main.rs:206:17
        |
    206 |                 #[cfg(target_os = "windows")]
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    error: aborting due to 2 previous errors
    
    For more information about this error, try `rustc --explain E0658`.
    error: could not compile `enginesound`
    
    To learn more, run the command again with --verbose.
    

    There are 9 warnings before this, but are all related to never used functions or constants.

    opened by Saitodepaula 2
  • New Feature

    New Feature

    Hi, It would be awesome to change the rpms in real-time through stdin (and not only the slider in the GUI). This would help a lot in interfacing the simulator with other scripts!

    opened by matchild 2
  • Dependencies to alsa, libxcb-shape0-dev and libxcb-xfixes0-dev

    Dependencies to alsa, libxcb-shape0-dev and libxcb-xfixes0-dev

    Hey,

    thanks for providing the code for this great project!

    When trying to build your project on a vanilla Ubuntu (focal) system, I had to install several additional packages to get through the build process:

    Errors

    error: failed to run custom build command for `alsa-sys v0.3.0`
    
      = note: /usr/bin/ld: cannot find -lxcb-shape
              /usr/bin/ld: cannot find -lxcb-xfixes
              collect2: error: ld returned 1 exit status
    

    Solution

    Install packages libasound2-dev, libxcb-shape0-dev and libxcb-xfixes0-dev, e.g. via:

    sudo apt-get install libasound2-dev libxcb-shape0-dev libxcb-xfixes0-dev
    

    Maybe these dependencies could be added to the README.md file to make it transparent what's required.

    opened by leosh64 1
  • Bump smallvec from 1.5.1 to 1.8.0

    Bump smallvec from 1.5.1 to 1.8.0

    Bumps smallvec from 1.5.1 to 1.8.0.

    Release notes

    Sourced from smallvec's releases.

    v1.8.0

    • Add optional support for the arbitrary crate (#275).

    v1.7.0

    • new_const and from_const constructors for creating a SmallVec in const contexts. Requires Rust 1.51 and the optional const_new feature. (#265)

    v1.6.1

    • Fix a possible buffer overflow in insert_many (#252, #254).

    v1.6.0

    • The "union" feature is now compatible with stable Rust 1.49 (#248, #247).
    • Fixed warnings when compiling with Rust 1.51 nightly (#242, #246).
    Commits
    • 0a4fdff Version 1.8.0
    • 6d0dea5 Auto merge of #275 - as-com:arbitrary-support, r=mbrubeck
    • 9bcd950 Add support for arbitrary
    • 7cbb3b1 Auto merge of #271 - saethlin:drain-aliasing-test, r=jdm
    • 0fced9d Test for drains that shift the tail, when inline
    • 218e0bb Merge pull request #270 from servo/github-actions
    • 52c50af Replace TravisCI with Github Actions.
    • 5ae217a Include the cost of shifts in insert/remove benchmarks (#268)
    • 58edc0e Version 1.7.0
    • 1e4b151 Added feature const_new which enables SmallVec::new_const() (#265)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump tar from 0.4.30 to 0.4.38

    Bump tar from 0.4.30 to 0.4.38

    Bumps tar from 0.4.30 to 0.4.38.

    Commits
    • dc78ebe Bump to 0.4.38
    • de72a30 Add a method to write a link name without canonicalization (#274)
    • ec5edf1 Add an append_link() method to handle long link targets (#273)
    • 5a1c8ea Add public constructor for PaxExtensions (#271)
    • 8333ef6 Avoid reallocating Strings when creating TarError (#269)
    • 1890555 Consolidate some methods and tweak some lifetimes
    • 64b8e1b Add support for readers that implement Seek (#218) (#266)
    • a2a82e6 Fix the second overflow with self.next
    • de08ca1 Fix an overflow when rounding up the size of a file
    • 60c6bd8 Use rust birthday for HeaderMode::Deterministic timestamp (#262)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump regex from 1.4.2 to 1.5.6

    Bump regex from 1.4.2 to 1.5.6

    Bumps regex from 1.4.2 to 1.5.6.

    Changelog

    Sourced from regex's changelog.

    1.5.6 (2022-05-20)

    This release includes a few bug fixes, including a bug that produced incorrect matches when a non-greedy ? operator was used.

    1.5.5 (2022-03-08)

    This releases fixes a security bug in the regex compiler. This bug permits a vector for a denial-of-service attack in cases where the regex being compiled is untrusted. There are no known problems where the regex is itself trusted, including in cases of untrusted haystacks.

    1.5.4 (2021-05-06)

    This release fixes another compilation failure when building regex. This time, the fix is for when the pattern feature is enabled, which only works on nightly Rust. CI has been updated to test this case.

    1.5.3 (2021-05-01)

    This releases fixes a bug when building regex with only the unicode-perl feature. It turns out that while CI was building this configuration, it wasn't actually failing the overall build on a failed compilation.

    1.5.2 (2021-05-01)

    This release fixes a performance bug when Unicode word boundaries are used.

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Releases(v1.6)
Owner
πŸ¦€ πŸ¦€ πŸ¦€
null
A CLI and library to convert data to sound, and vice versa (dependency-free)

Data to sound A simple crate to convert data to sound, and sound to data. The sound file format is wave (.wav). You can use it as a library or as a co

Awiteb 8 Feb 28, 2023
MIDI-controlled stereo-preserving granular-synthesizer LV2 plugin

Stereog "Stereog" rhymes with "hairy dog." Stereog is a MIDI-controlled stereo-preserving granular synthesizer LV2 plugin. It is experimental software

Ed Cashin 6 Jun 3, 2022
A Rust environment for sound synthesis and algorithmic composition.

Sorceress A Rust environment for sound synthesis and algorithmic composition, powered by SuperCollider. Overview Sorceress is a Rust crate that provid

Wesley Merkel 82 Dec 26, 2022
Rust Sound Synthesis Library

Oscen Oscen [β€œoh-sin”] is a library for building modular synthesizers in Rust. It contains a collection of components frequently used in sound synthes

Reed Rosenbluth 104 Nov 2, 2022
A very simple audio synthesizer with a tuix gui

In this tutorial we'll create a very simple audio synthesiser application from scratch with a ui using tuix. The finished code for this tutorial can b

George Atkinson 24 Jan 6, 2023
A simple GUI audio player written in Rust with egui. Inspired by foobar2000.

Music Player A simple GUI music player inspired by foobar2000 written in Rust using egui. The goal of this project is to learn about making gui/ nativ

Ryan Blecher 5 Sep 16, 2022
Psst - Fast and multi-platform Spotify client with native GUI

Psst Fast Spotify client with native GUI, without Electron, built in Rust. Very early in development, lacking in features, stability, and general user

Jan Pochyla 7.2k Jan 2, 2023
A simple GUI rust application that keeps track of how much time you spend on each application.

TimeSpent A simple GUI rust application that keeps track of how much time you spend on each application. Installation Click here to download the Setup

Slacked Lime 4 Sep 23, 2022
Polyrhythmically-inclinded Midi Drum generator

Polyrhythmix Polyrhythmix (Poly) is a command-line assistant designed to generate MIDI files from the description of drum parts. It provides a conveni

Denis Redozubov 234 Jul 3, 2023
Rust bindings for the soloud audio engine library

soloud-rs A crossplatform Rust bindings for the soloud audio engine library. Supported formats: wav, mp3, ogg, flac. The library also comes with a spe

Mohammed Alyousef 38 Dec 8, 2022
A simple CLI audio player with strange features.

legacylisten legacylisten is a simple CLI audio player I wrote because no existing one fulfilled my needs. The main feature is that you can change how

Matthias Kaak 3 Jun 8, 2022
CLI Rust Audio Visualizer

crav Console-based Rust Audio Visualizer It can run in the terminal but also has a 3D accelerated backend implemented in wgpu. demo compatibility The

null 20 Oct 16, 2022
Minimalist multi-track audio recorder which may be controlled via OSC or MIDI.

smrec Minimalist multi-track audio recorder which may be controlled via OSC or MIDI. I did this because I needed a simple multi-track audio recorder w

Ali Somay 18 Oct 22, 2023
PostgreSQL procedural language handler for Clojure via SCI

pl/sci Status This is very much an experiment and I'm open to feedback on where to take this next. Build Requirements lein GraalVM CE 20.3.0 Java 11 c

Michiel Borkent 45 Nov 28, 2022
πŸ“œπŸ”πŸŽΆ A CLI which converts morse code into sound

morse2sound ?? A CLI which converts morse code to sound Big shoutout to Br1ght0ne for guiding me how to use Rust on stream

Ilya Revenko 15 Dec 4, 2022
A Rust CLI that makes mechanical keyboard sound effects on every key press

Rustyvibes A Rust CLI that makes mechanical keyboard sound effects on every key press Rustyvibes.mp4 Installation macOS: brew install kb24x7/rustyvibe

Kunal Bagaria 95 Dec 14, 2022
A CLI and library to convert data to sound, and vice versa (dependency-free)

Data to sound A simple crate to convert data to sound, and sound to data. The sound file format is wave (.wav). You can use it as a library or as a co

Awiteb 8 Feb 28, 2023
🌎 Demo for Minecraft-like procedural generation using the Bevy game engine

infinigen This is a demo for Minecraft-like procedural generation using the Bevy game engine. chunks along all axes (X, Y and Z) adjustable zoom level

James Hiew 16 Jun 11, 2023
A LED Christmas Tree controlled by Rust. Contribute your own renderers!

Rusty Christmas Tree This is code that draws on the LED Christmas Tree made by @aidancrowther. You can see his 3D design files and Pi Pico setup code

Forest Anderson 43 May 15, 2022
Distributed, version controlled, SQL database with cryptographically verifiable storage, queries and results. Think git for postgres.

SDB - SignatureDB Distributed, version controlled, SQL database with cryptographically verifiable storage, queries and results. Think git for postgres

Fremantle Industries 5 Apr 26, 2022