Skip to content

Commit

Permalink
Merge pull request #66 from HEnquist/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
HEnquist authored Sep 24, 2020
2 parents 6b40746 + 5662843 commit e41e25d
Show file tree
Hide file tree
Showing 28 changed files with 1,632 additions and 694 deletions.
60 changes: 60 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## 0.3.2
New features:
- New commands to get more information from the websocket server.
- Possible to skip lines or bytes in coefficient files.
- Updated Cpal library.
- Added capture and playback devices Stdin & Stdout.
- Improved error messages.
- Improved validation of mixer config
- Added option to set which IP address to bind websocket server to

Bugfixes:
- Fix websocket `exit` command.
- Correct response of `setconfigname` websocket command.
- Fix buffer underrun soon after starting Alsa playback.
- Correct scaling of FIR coefficients when reloading config.


## 0.3.1
New features:
- Rate adjust via the resampler also for Wasapi and CoreAudio.


## 0.3.0
New features:
- Support for Windows (Wasapi) and macOS (CoreAudio) via the Cpal library.


## 0.2.2
New features:
- Fix building on Windows and macOS.
- Updated versions of several libraries.
- Improved speed from optimization of several important loops.


## 0.2.1
New features:
- Convolver was optimized to be up to a factor 2 faster.

## 0.2.0
New features:
- Synchronous resampler that replaces the previous FastSync, BalancedSync and AccurateSync types with a single one called Synchronous. This uses FFT for a major speedup.
- The Async resamplers have been optimized and are now around a factor 2 faster than before.

Bugfixes:
- Fixed error when setting Alsa buffer size in some cases.


## 0.1.0
New features:
- Support for asynchronous resampling in all backends.
- Added S24LE3 format (corresponds to Alsa S24_3LE)
- File capture device can skip a number of bytes at the beginning of a file and then read a limited number of bytes

Other:
- Alsa backend rewritten to reduce code duplication
- Improved debug output


## 0.0.14
Last version without resampling
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "camilladsp"
version = "0.3.1"
version = "0.3.2"
authors = ["Henrik Enquist <[email protected]>"]
description = "A flexible tool for processing audio"

Expand Down Expand Up @@ -28,6 +28,7 @@ alsa = { version = "0.4", optional = true }
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.8"
serde_json = "1.0"
serde_with = "1.4.0"
realfft = "0.2.0"
fftw = { version = "0.6.2", optional = true }
Expand All @@ -42,7 +43,7 @@ ws = { version = "0.9.1", optional = true }
libpulse-binding = { version = "2.0", optional = true }
libpulse-simple-binding = { version = "2.0", optional = true }
rubato = "0.4.3"
cpal = { version = "0.11.0", optional = true }
cpal = { version = "0.12.1", optional = true }

[dev-dependencies]
criterion = "0.3"
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ ENV PKG_CONFIG_PATH /usr/lib/arm-linux-gnueabihf/pkgconfig/

RUN dpkg --add-architecture armhf && \
apt-get update && \
apt-get install libasound2-dev:armhf -y && \
apt-get install libpulse0 libpulse-dev:armhf -y \
apt-get install libasound2-dev:armhf -y \
120 changes: 73 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ This starts the processing defined in the specified config file. The config is f
Starting with the --help flag prints a short help message:
```
> camilladsp --help
CamillaDSP 0.1.0
CamillaDSP 0.3.2
Henrik Enquist <[email protected]>
A flexible tool for processing audio
Expand All @@ -247,7 +247,8 @@ FLAGS:
-w, --wait Wait for config from websocket
OPTIONS:
-p, --port <port> Port for websocket server
-a, --address <address> IP address to bind websocket server to
-p, --port <port> Port for websocket server
ARGS:
<configfile> The configuration file to use
Expand All @@ -256,6 +257,8 @@ If the "check" flag is given, the program will exit after checking the configura

To enable the websocket server, provide a port number with the `-p` option. Leave it out, or give 0 to disable.

By default the websocket server binds to the address 127.0.0.1 which means it's only accessible locally. If it should be also available to remote machines, give the IP address of the interface where it should be available with the `-a` option. Giving 0.0.0.0 will bind to all interfaces.

If the "wait" flag, `-w` is given, CamillaDSP will start the websocket server and wait for a configuration to be uploaded. Then the config file argument must be left out.

The default logging setting prints messages of levels "error", "warn" and "info". By passing the verbosity flag once, `-v` it also prints "debug". If and if's given twice, `-vv`, it also prints "trace" messages.
Expand All @@ -267,8 +270,6 @@ The configuration can be reloaded without restarting by sending a SIGHUP to the
## Controlling via websocket
See the [separate readme for the websocket server](./websocket.md)

If the websocket server is enabled with the -p option, CamillaDSP will listen to incoming websocket connections on the specified port.


# Capturing audio

Expand Down Expand Up @@ -306,21 +307,19 @@ Set VB-CABLE as the default playback device in the control panel, and let Camill

The device name is the same as seen in the Windows volume control. For example, the VB-CABLE device name is "CABLE Output (VB-Audio Virtual Cable)". The device name is built from the inpout/output name and card name, and the format is "{input/output name} ({card name})".

The sample format appears to always be 32-bit float (FLOAT32LE).
The sample format is always 32-bit float (FLOAT32LE) even if the device is configured to use aother format.

The sample rate must match the default format of the device. To change this, open "Sound" in the Control panel, select the sound card, and click "Properties". Then open the "Advanced" tab and select the desired format under "Default Format".


## CoreAudio
CoreAudio is supported by the cpal library and should work, but hasn't actually been tested.

To capture audio from applications a virtual sound card is needed. See for example [BlackHole](https://github.com/ExistentialAudio/BlackHole).
To capture audio from applications a virtual sound card is needed. This has been verified to work well with [Soundflower](https://github.com/mattingalls/Soundflower)

Set the virtual sound card as the default playback device in the Sound preferences, and let CamillaDSP capture from the output of this card.

The device name is the same as the one shown in System Preferences / Sound.
The device name is the same as the one shown in the "Audio MIDI Setup" that can be found under "Other" in Launchpad. The name for the 2-channel interface of Soundflower is "Soundflower (2ch)", and the built in audio in a MacBook Pro is called "Built-in Output".

The sample format appears to always be 32-bit float (FLOAT32LE).
The sample format is always 32-bit float (FLOAT32LE) even if the device is configured to use another format.


# Configuration
Expand Down Expand Up @@ -440,9 +439,18 @@ devices:


* `capture` and `playback`

Input and output devices are defined in the same way.
A device needs:
* `type`: Alsa, Pulse, Wasapi, CoreAudio or File
* `type`:
The available types depend on which features that were included when compiling. All possible types are:
* `Alsa`
* `Pulse`
* `Wasapi`
* `CoreAudio`
* `File`
* `Stdin` (capture only)
* `Stdout` (playback only)
* `channels`: number of channels
* `device`: device name (for Alsa, Pulse, Wasapi, CoreAudio)
* `filename` path the the file (for File)
Expand All @@ -456,42 +464,42 @@ devices:
* FLOAT32LE - 32 bit float, stored as four bytes
* FLOAT64LE - 64 bit float, stored as eight bytes

Supported formats:
| | Alsa | Pulse | Wasapi | CoreAudio |
|------------|--------------------|--------------------|--------------------|--------------------|
| S16LE | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| S24LE | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: |
| S24LE3 | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: |
| S32LE | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: |
| FLOAT32LE | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| FLOAT64LE | :heavy_check_mark: | :x: | :x: | :x: |


Equivalent formats (for reference):
| CamillaDSP | Alsa | Pulse |
|------------|------------|-----------|
| S16LE | S16_LE | S16LE |
| S24LE | S24_LE | S24_32LE |
| S24LE3 | S24_3LE | S24LE |
| S32LE | S32_LE | S32LE |
| FLOAT32LE | FLOAT_LE | FLOAT32LE |
| FLOAT64LE | FLOAT64_LE | - |

The File capture device supports two additional optional parameters, for advanced handling of raw files and testing:
* `skip_bytes`: Number of bytes to skip at the beginning of the file. This can be used to skip over the header of some formats like .wav (which typocally has a fixed size 44-byte header). Leaving it out or setting to zero means no bytes are skipped.
* `read_bytes`: Read only up until the specified number of bytes. Leave it out to read until the end of the file.

The File device type reads or writes to a file.
The format is raw interleaved samples, 2 bytes per sample for 16-bit,
and 4 bytes per sample for 24 and 32 bits.
If the capture device reaches the end of a file, the program will exit once all chunks have been played.
That delayed sound that would end up in a later chunk will be cut off. To avoid this, set the optional parameter `extra_samples` for the File capture device.
This causes the capture device to yield the given number of samples (per channel) after reaching end of file, allowing any delayed sound to be played back.
By setting the filename to `/dev/stdin` for capture, or `/dev/stdout` for playback, the sound will be written to or read from stdio, so one can play with pipes:
```
> camilladsp stdio_capt.yml > rawfile.dat
> cat rawfile.dat | camilladsp stdio_pb.yml
```
Supported formats:
| | Alsa | Pulse | Wasapi | CoreAudio | File/Stdin/Stdout |
|------------|--------------------|--------------------|--------------------|--------------------|--------------------|
| S16LE | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| S24LE | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :heavy_check_mark: |
| S24LE3 | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :heavy_check_mark: |
| S32LE | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :heavy_check_mark: |
| FLOAT32LE | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| FLOAT64LE | :heavy_check_mark: | :x: | :x: | :x: | :heavy_check_mark: |
Equivalent formats (for reference):
| CamillaDSP | Alsa | Pulse |
|------------|------------|-----------|
| S16LE | S16_LE | S16LE |
| S24LE | S24_LE | S24_32LE |
| S24LE3 | S24_3LE | S24LE |
| S32LE | S32_LE | S32LE |
| FLOAT32LE | FLOAT_LE | FLOAT32LE |
| FLOAT64LE | FLOAT64_LE | - |
The __File__ device type reads or writes to a file, while __Stdin__ reads from stdin and __Stdout__ writes to stdout.
The format is raw interleaved samples, in the selected sample format.
If the capture device reaches the end of a file, the program will exit once all chunks have been played.
That delayed sound that would end up in a later chunk will be cut off. To avoid this, set the optional parameter `extra_samples` for the File capture device.
This causes the capture device to yield the given number of samples (per channel) after reaching end of file, allowing any delayed sound to be played back.
The __Stdin__ capture device and __Stdout__ playback device use stdin and stdout, so it's possible to easily pipe audio between applications:
```
> camilladsp stdio_capt.yml > rawfile.dat
> cat rawfile.dat | camilladsp stdio_pb.yml
```
Note: On Unix-like systems it's also possible to use the File device and set the filename to `/dev/stdin` for capture, or `/dev/stdout` for playback.
The __File__ and __Stdin__ capture devices support two additional optional parameters, for advanced handling of raw files and testing:
* `skip_bytes`: Number of bytes to skip at the beginning of the file or stream. This can be used to skip over the header of some formats like .wav (which typically has a fixed size 44-byte header). Leaving it out or setting to zero means no bytes are skipped.
* `read_bytes`: Read only up until the specified number of bytes. Leave it out to read until the end of the file or stream.
## Resampling
Expand Down Expand Up @@ -644,7 +652,25 @@ filters:
type: File
filename: path/to/filter.txt
format: TEXT
skip_bytes_lines: 0 (*)
read_bytes_lines: 0 (*)
```
The `type` can be "File" of "Values". Use "File" to load a file, and "Values" for giving the coefficients directly in the configuration file.
Example for giving values:
```
filters:
lowpass_fir:
type: Conv
parameters:
type: Values
values: [0.0, 0.1, 0.2, 0.3]
```
The File type supports two additional optional parameters, for advanced handling of raw files and text files with headers:
* `skip_bytes_lines`: Number of bytes (for raw files) or lines (for text) to skip at the beginning of the file. This can be used to skip over a header. Leaving it out or setting to zero means no bytes or lines are skipped.
* `read_bytes_lines`: Read only up until the specified number of bytes (for raw files) or lines (for text). Leave it out to read until the end of the file.
For testing purposes the entire "parameters" block can be left out (or commented out with a # at the start of each line). This then becomes a dummy filter that does not affect the signal.
The "format" parameter can be omitted, in which case it's assumed that the format is TEXT. This format is a simple text file with one value per row:
```
Expand Down
8 changes: 4 additions & 4 deletions exampleconfigs/simpleconfig_plot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ filters:
peak1:
type: Biquad
parameters:
type: Highshelf
freq: 1000
slope: 15
gain: -6
type: Peaking
freq: 100
q: 2.0
gain: -20

mixers:
mono:
Expand Down
3 changes: 1 addition & 2 deletions exampleconfigs/stdio_capt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ devices:
device: "MySink.monitor"
format: S16LE
playback:
type: File
type: Stdout
channels: 2
filename: "/dev/stdout"
format: S16LE
6 changes: 2 additions & 4 deletions exampleconfigs/stdio_inout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ devices:
silence_threshold: -60
silence_timeout: 3.0
capture:
type: File
type: Stdin
channels: 2
filename: "/dev/stdin"
format: S16LE
playback:
type: File
type: Stdout
channels: 2
filename: "/dev/stdout"
format: S16LE
3 changes: 1 addition & 2 deletions exampleconfigs/stdio_pb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ devices:
silence_threshold: -60
silence_timeout: 3.0
capture:
type: File
type: Stdin
channels: 2
filename: "/dev/stdin"
format: S16LE
playback:
type: Pulse
Expand Down
Loading

0 comments on commit e41e25d

Please sign in to comment.