cute_dsp is a C API for various DSP effects suitable for video games

Related tags

Audio cute_dsp
Overview

cute_dsp

cute_dsp is a C API for various DSP effects suitable for video games and meant to interface directly with the cute_sound library created by Randy Gaul. The scope of cute_dsp will eventually include:

  • Lowpass filter
  • Highpass filter
  • White noise injection
  • Lowpass filtering with resonances
  • Wind noise presets for resonant filters
  • Realtime reverb
  • Echo filter
  • Randomization settings
  • Filter presets

Implemented Features

Lowpass Filtering

Uses a second order Butterworth filter with a 6dB per octave rolloff, with added resonance.

Highpass Filtering

Uses a second order Butterworth filter with a 6dB per octave rolloff, converted from the lowpass filter equation, without resonance.

Echo Filtering

Uses two ring buffers for delay of input and output samples. There are three designable parameters:

  • Delay time
  • Mix factor (echo loudness)
  • Feedback factor (amount that echoes feedback into themselves)

Noise Generator

Generates white noise and adds to a signal. The signal path of cute_dsp allows this white noise to be fed into other filters in the signal chain. The white noise is generated using a xorshift128 PRNG.

Usage

cute_dsp must be used concurrently with cute_sound.

To set up cute_dsp, #include "cute_dsp.h" somewhere below your include for cute_sound.h. Above the include to cute_dsp, there must be one place where you #define CUTE_DSP_IMPLEMENTATION.

cd_context_t

After creating your cs_context_t cute sound context, you will need to create a cute_dsp context.

cs_context_t* sound_context = cs_make_context(...);

cd_context_def_t dsp_context_definition; // statically create dsp context

// set the max number of mixers
dsp_context_definition.playing_pool_count = num_elements_in_playing_pool;

// set dsp sampling rate
dsp_context_definition.sampling_rate = (float)frequency;

// set which filters you would like to use and some optional parameters
dsp_context_definition.use_highpass = 1;
dsp_context_definition.use_lowpass = 1;
dsp_context_definition.use_echo = 0;
dsp_context_definition.use_noise = 1;
dsp_context_definition.echo_max_delay_s = 0.f;
dsp_context_definition.rand_seed = 2;

// allocate the context
cd_context_t* dsp_context = cd_make_context(dsp_context_definition);

//...

// at the end of the application, after shutting down the sound context, release the dsp context
cs_shutdown_context(sound_context);
cd_release_context(&dsp_context);

For each sound played using cute_sound, there will be a copy of each filter you've enabled added as a cute_sound plugin. However, the filter will by default set its internal values such that the effect of the filter is not audible. I.e. if you've enabled lowpass filters in cd_context_def_t, then each sound played using cute_sound will have an instance of a lowpass filter. That lowpass filter will have its cutoff frequency at 20kHz, therefore negating its effect.

cd_lowpass_t/cd_highpass_t

To modify the cutoff frequencies of the lowpass/highpass filters:

void cd_set_lowpass_cutoff(cs_playing_sound_t* playing_sound, float cutoff_in_hz);
void cd_set_lowpass_resonance(cs_playing_sound_t* playing_sound, float resonance);
void cd_set_highpass_cutoff(cs_playing_sound_t* playing_sound, float cutoff_in_hz);

float cd_get_lowpass_cutoff(const cs_playing_sound_t* playing_sound);
float cd_get_lowpass_resonance(const cs_playing_sound_t* playing_sound);
float cd_get_highpass_cutoff(const cs_playing_sound_t* playing_sound);

Cutoff frequency is limited to the range of frequencies able to be heard by humans, [20, 20,000] Hz. Resonance is limited to the range of [0, 1].

cd_echo_t

To modify the parameters of the echo filter:

void cd_set_echo_delay(cs_playing_sound_t* playing_sound, float t);
void cd_set_echo_mix(cs_playing_sound_t* playing_sound, float a);
void cd_set_echo_feedback(cs_playing_sound_t* playing_sound, float b);

float cd_get_echo_delay(const cs_playing_sound_t* playing_sound);
float cd_get_echo_mix(const cs_playing_sound_t* playing_sound);
float cd_get_echo_feedback(const cs_playing_sound_t* playing_sound);
float cd_get_echo_max_delay(const cs_playing_sound_t* playing_sound);

cd_noise_t

To modify the parameters of the noise generator:

void cd_set_noise_amplitude_db(cs_playing_sound_t* playing_sound, float db);
void cd_set_noise_amplitude_gain(cs_playing_sound_t* playing_sound, float gain);

float cd_get_noise_amplitude_db(const cs_playing_sound_t* playing_sound);
float cd_get_noise_amplitude_gain(const cs_playing_sound_t* playing_sound);
You might also like...
Block all ads in vídeo, áudio, banner, anti-skip

NoAdSpotify Block spotify ad This is an updated and simplified version of the project: BlockTheSpot Last updated: 6th June 2021 Last tested version: 1

Example for transmit video + audio to tv via hackRF

Этот код может передавать звук и изображение на телевизор через hackRF В этом проекте использовался код из следующих репозиториев: https://github.com/

Single file C library for decoding MPEG1 Video and MP2 Audio

PL_MPEG - MPEG1 Video decoder, MP2 Audio decoder, MPEG-PS demuxer Single-file MIT licensed library for C/C++ See pl_mpeg.h for the documentation. Why?

vintage - a declarative API for C++ audio plug-ins

This is an experiment in seeing how far modern C++ features allow to write purely declarative code and introspect this code through various reflection-like features.

Audio Plugin API

Audio Plugin API

This is a list of different open-source video games and commercial video games open-source remakes.

This is a list of different open-source video games and commercial video games open-source remakes.

Video stabilization is a software-based approach in real-time to eliminating environmental effects (wind, heavy vehicle etc.) and enhance the visual performance that degrade video streaming quality.
Video stabilization is a software-based approach in real-time to eliminating environmental effects (wind, heavy vehicle etc.) and enhance the visual performance that degrade video streaming quality.

Video Stabilization Contents General Info Installation To Do General Info Video stabilization is a software-based approach in real-time to eliminating

A multi core friendly rigid body physics and collision detection library suitable for games and VR applications.
A multi core friendly rigid body physics and collision detection library suitable for games and VR applications.

Jolt Physics Library A multi core friendly rigid body physics and collision detection library suitable for games and VR applications. A YouTube video

A multi core friendly rigid body physics and collision detection library suitable for games and VR applications.
A multi core friendly rigid body physics and collision detection library suitable for games and VR applications.

A multi core friendly rigid body physics and collision detection library suitable for games and VR applications.

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.
Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.

Bullet Physics SDK This is the official C++ source code repository of the Bullet Physics SDK: real-time collision detection and multi-physics simulati

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.
Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.

`lv_lib_100ask` is a reference for various out of the box schemes based on lvgl library or an enhanced interface for various components of lvgl library.

Introduction lv_lib_100ask is a reference for various out of the box schemes based on lvgl library or an enhanced interface for various components of

A lightweight, secure, easy-to-use crypto library suitable for constrained environments.
A lightweight, secure, easy-to-use crypto library suitable for constrained environments.

The Hydrogen library is a small, easy-to-use, hard-to-misuse cryptographic library. Features: Consistent high-level API, inspired by libsodium. Instea

A competitive programming helper tool, which packages included libraries into a single file, suitable for online judges.

cpack Cpack is a competitive programming helper tool, which packages the main source file along with included libraries into a single file, suitable f

Cross-platform tool to extract wavetables and draw envelopes from sample files, exporting the wavetable and generating the appropriate SFZ text to use in a suitable player.
Cross-platform tool to extract wavetables and draw envelopes from sample files, exporting the wavetable and generating the appropriate SFZ text to use in a suitable player.

wextract Cross-platform tool to extract wavetables and draw envelopes from sample files, exporting the wavetable and generating the appropriate SFZ te

This work is an expend version of livox_camera_calib(hku-mars/livox_camera_calib), which is suitable for spinning LiDAR。
This work is an expend version of livox_camera_calib(hku-mars/livox_camera_calib), which is suitable for spinning LiDAR。

expend_lidar_camera_calib This work is an expend version of livox_camera_calib, which is suitable for spinning LiDAR。 In order to apply this algorithm

Stereo_QT is suitable for CHUSEI 3D Webcam
Stereo_QT is suitable for CHUSEI 3D Webcam

Stereo_QT is suitable for CHUSEI 3D Webcam

Generic single-file implementations of AVL tree in C and C++ suitable for deeply embedded systems
Generic single-file implementations of AVL tree in C and C++ suitable for deeply embedded systems

Cavl Generic single-file implementation of AVL tree suitable for deeply embedded systems. Simply copy cavl.h or cavl.hpp (depending on which language

Comments
  • cute_dsp causes cute_sound to crash in cs_mix

    cute_dsp causes cute_sound to crash in cs_mix

    Running on Window 10 using cute_sound 1.11. Compiling with Visual Studio.

    Running (cute_dsp) echo_test causes (cute_sound) cs_mix to crash due to...

    Unhandled exception: 0xC0000005: Access violation reading location 0xffffffff.
    

    ...at this line in cs_mix (in cute_sound):

    // apply volume, load samples into float buffers
    switch (loaded->channel_count)
    {
    case 1:
        for (int i = delay_wide; i < mix_wide - delay_wide; ++i) {
            cs__m128 A = cA[i + offset_wide]; // THIS LINE CRASHES
    

    I also tried adding cute_dsp to both the cute_sound test files, and my project. All produce the same outcome -- that crash in cs_mix.

    BTW notice this line vanilla echo_test:

    int buffered_seconds = 5; // number of seconds the buffer will hold in memory. want this long enough in case of frame-delays
    

    In echo_test, that parameter is passed into cs_make_context:

    cs_context_t* sound_ctx = cs_make_context(GetActiveWindow(), frequency, /*latency_in_Hz,*/ buffered_seconds, num_elements_in_playing_pool, 0);
    

    The parameter passed in as "buffered_seconds" is actually buffered_samples. The units are samples, not seconds. So "5" is probably not a reasonable value. So I increased that to various values, including 8192 and up. To test my understanding of this parameter, I passed in "5" in the cute_sound test code and the outcome was that no sound played.

    opened by mijagourlay 1
Owner
Matt Rosen
Game Audio/Game Engine programmer DigiPen Institute of Technology, graduated April 2020. Current position: Audio Programmer at Larian Studios
Matt Rosen
multichannel eurorack dsp platform

Nemesis multichannel dsp platform for eurorack \hardware panel, pcb and gerber files \software project template \doc datasheets and additional informa

Arev Imer 25 Dec 3, 2022
A lightweight music DSP library.

Soundpipe Soundpipe is a lightweight music DSP library written in C. It aims to provide a set of high-quality DSP modules for composers, sound designe

Paul Batchelor 102 Dec 14, 2021
DSP C++ audio filters

DSP filters in C++ This repo contains some DSP biquad filters used in audio. I've extracted those filters from the Designing Audio Effect Plug-Ins in

Dimitris Tassopoulos 101 Dec 26, 2022
Sexy, audio-responsive effects on LED strips.

Striptease Sexy, audio-responsive effects on LED strips. For Teensy 4 with Audio Adapter Board, by PJRC. Quick demo Shooting video of LEDs is very tri

Luca Paolini 35 Jun 19, 2022
BYOD is a guitar distortion plugin with a customisable signal chain that allows users to create their own guitar distortion effects.

BYOD is a guitar distortion plugin with a customisable signal chain that allows users to create their own guitar distortion effects. The plugin contains a wide variety of distortion effects from analog modelled circuits to purely digital creations, along with some musical tone-shaping filters, and a handful of other useful processing blocks.

null 229 Jan 5, 2023
Open source digital sound effects based on JACK audio connection kit.

Noiseworks Digital Audio Effects Repository Open source digital sound effects based on JACK audio connection kit. This repository is intended to provi

null 5 Jul 29, 2022
C library for audio noise reduction and other spectral effects

libspecbleach C library for audio noise reduction and other spectral effects Background This library is based on the algorithms that were used in nois

Luciano Dato 43 Dec 15, 2022
🎵 Music notation engraving library for MEI with MusicXML and Humdrum support and various toolkits (JavaScript, Python)

Verovio is a fast, portable and lightweight library for engraving Music Encoding Initiative (MEI) digital scores into SVG images. Verovio also contain

RISM Switzerland 519 Jan 1, 2023
An audio mixer that supports various file formats for Simple Directmedia Layer.

An audio mixer that supports various file formats for Simple Directmedia Layer.

Simple Directmedia Layer 198 Dec 26, 2022
An OBS plugin for removing background in portrait images (video), making it easy to replace the background when screen recording.

OBS Plugin: Background Removal Introduction Building MacOSX Linux / Ubuntu Windows Download Check out the latest releases for downloads and install in

Roy Shilkrot 1.4k Jan 8, 2023