Skip to content

An experiment in collaborative broadcast streaming computer-generated music, in Clojure

License

Notifications You must be signed in to change notification settings

rm-hull/sound-flour

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sound-Flour

Build Status Coverage Status Dependencies Status Maintenance

NOTE: This project is undergoing significant rework

Sound-flour is:

Background

Watching https://www.youtube.com/watch?v=GtQdIYUtAHg and subsequently trying it blew me away somehow.

The fact that a simple C program fragment like:

(t*(t>>5|t>>8))>>(t>>16)

or

(t%(t/(t>>9|t>>13)))

can produce an audio wave that, although arguably isn't music in the conventional sense, produces something that is rhythmic, fanciful and interestingly rich, but somehow intensely annoying. Its not white noise by any stretch, as you can discern repeating structure amongst the chaos: nevertheless, it is addictive to hang on (and on) waiting for a fleeting moment of melody to only to melt away almost before it it happened.

The Proposition

So it's easy to write a program to generate random sound, right? This pretty much nails it here: http://wurstcaptures.untergrund.net/music/, so maybe we should pack up now and go home.

Well... while that's pretty good, its a bit low-level, and you can only have so much fun munging bits all day. We want something more... social... gamific... We have a clojure sandbox, so lets allow gists (or listen in on tweets) to provide some clojure SEXPs to generate some interesting stream data.

In theory, we could generate something altogether a bit smoother maybe:

(def buffer-len 8000)

(def sample-rate 8000)

(defn sine-wave [frequency amplitude]
  (let [data (->>
                (range buffer-len)
                (map #(* amplitude (Math/sin (/ (* 2 Math/PI % frequency) sample-rate))))
                (into []))]
    (fn [t] (data (mod t buffer-len)))))

(sine-wave 440 0.5) ; 440 Hz = Middle C

Which returns a function that driven with a sampling tick, returns a value in the range ±1.0 that when streamed out, would approximate middle C.

A sine wave on its own is pretty boring; it only becomes interesting when it can be composed with other functions, c.f. Functional Composition by Chris Ford, so perhaps we can build on top of this basic function, perhaps there should be multiple channels that get mixed before being streamed, maybe there should be stereo output, ...

What this project actually is

A web framework, in clojure, for processing gists (also in clojure) in which a nominated function translates an ever increating time-quantum in some musically interesting way, mixes it with other gists' functions, collects the resultant data into a stream, encodes to a WAV before chunking and broadcasting to anyone who may be listening. And, as time permits, to include some real-time visualization of broadcast audio data.

What will make it work?

I see it working at three levels:

  • Framework + nothing = something not interesting

  • Framework + my gists = something possibly interesting

  • Framework + YOUR gists = something really interesting

So why shouldn't I just use Overtone?

You probably should, and I may end up doing so too...

Examples

TODO

Inspiration

In no particular order, ideas borrowed heavily from:

TODO

Everything?

References

License

The MIT License (MIT)

Copyright (c) 2016 Richard Hull

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

An experiment in collaborative broadcast streaming computer-generated music, in Clojure

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published