Skip to content

willbinzi/arpeggio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

135 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arpeggio

Arpeggio provides audio processing functionality using FS2. It was created as an idea for a talk on implementing a pedalboard in Scala, which influences some of the nomenclature within the project. Slides for the aforementioned talk can be found here.

It currently provides implementations of tremolo, overdrive, delay and reverb effects.

Project setup

The project is compiled for JVM and native. The native version takes a considerable time to link, and is single threaded (until Cats Effect can be updated to Scala Native 0.5) but the input latency is considerably reduced.

See here for instructions on how to set up a working Scala Native environment.

The native version of the io module uses the portaudio C library for input and output. To manage this dependency, it uses sn-vcpkg which requires the dependencies mentioned here.

Overview

Arpeggio models an audio stream as an fs2.Stream[F, Float]. The audio can then be modified by applying instances of fs2.Pipe[F, Float, Float] (aliased to Pedal[F] within the project).

An audio stream that reads from the default audio device, along with an output sink that plays audio can be obtained using PlatformDefaultAudioInterface from the io module.

We can then run the audio from the input device, through a pedal (here the Schroeder reverb implementation included in the pedals module) and through the output device like so:

import arpeggio.io.PlatformDefaultAudioInterface
import arpeggio.pedals.reverb
import cats.effect.{IO, IOApp}

import scala.concurrent.duration.*

object Main extends IOApp.Simple:
  def run: IO[Unit] = PlatformDefaultAudioInterface
    .resource[IO]
    .use(interface =>
      interface.input
        .through(
          reverb.schroeder(predelay = 30.millis, decay = 1.second, mix = 0.7)
        )
        .through(interface.output)
        .compile
        .drain
    )

The above example is included in the project and can be run with:

sbt "exampleReverb/run"

Or, to run the JVM version:

sbt "exampleReverbJVM/run"

Special thanks

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages