Giter VIP home page Giter VIP logo

clj-audio's Introduction

clj-audio

This library is a general purpose audio library built on top of the Java Sound API. It comprises wrappers for JSA's sampled and midi packages in the corresponding namespaces. It also include a higher level API for audio playback in the core namespace.

The midi namespace is a work in progress.

Usage

(use 'clj-audio.core)

Playback

Playing a wave file.

(play (->stream "~/test.wav"))

Playing a MP3 file, this example requires some extra libraries, see "Installation" below.

(-> (->stream "~/test.mp3") decode play)

Decoding a MP3 file and writing it to a WAVE file.

(-> (->stream "~/test.mp3") decode (write :wave "~/test.wav"))

Skipping Audio Streams (experimental)

Skipping a specific amount of bytes.

(-> (->stream "~/test.mp3") (skip 1000) decode play)

Skipping a stream with a ratio of its length.

(let [s (->stream "~/test.mp3")
      skip (skipper s)]
  (skip 0.5)
  (-> s decode play))

Synthesizing Sounds (experimental)

Playing the resulting stream from applying the identity function from 0 to 99999. The given function output will be converted to bytes.

(play (->stream identity 100000))

Advanced Example

A simple headless MP3 player that support a basic set of command: play, stop, pause, next, previous, random and close. To use it, you'll need some external libraries as explained below. It should work for any file format given the corresponding SPI and adding their extensions to music-file-extensions.

Known Issues

  • Skipping an encoded stream then writing its decoded output to a file using the write function will produce an empty file.

Installation

This library is available on Clojars. To use clj-audio in your Leiningen project, add the following dependency.

[clj-audio "0.1.0"]

For encoded file type support, you'll need to add the corresponding Service Provider Interface (SPI) which are simple jar files. First you'll have to get the Tritonus plug-ins shared classes (tritonus_share-*.jar) which is needed by most JSA's SPI. Then to get MP3 support for example, you can grab the latest versions of JLayer and MP3SPI.

License

Copyright (c) Nicolas Buduroi. All rights reserved.

The use and distribution terms for this software are covered by the Eclipse Public License 1.0 which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license.

You must not remove this notice, or any other, from this software.

clj-audio's People

Contributors

budu avatar claj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

clj-audio's Issues

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.