makebreakbeat

makebreakbeat

make break beats.

img

this script is a wrapper for another script I wrote that generates breakbeats from a drum sample. I made this to learn more about sox and aubio as all the audio is generated with those tools.

Requirements

  • norns

Documentation

  • press K2 to generate beat
  • press K3 to toggle playing
  • use any E to change sample

to “break” a beat, this script first determines the tempo of the input file. it then determines onsets based on the tempo (minimum distance being sixteenth notes) and splits the input file into slices by onset markers. it then takes each slice and manipulates the slice with effects with some probability. the manipulated slice is then appended to an audio file at a position quantized to the desired tempo (set by norns clock). all the effect probabilities are available to modify in the parameters.

  • deviation: probability of deviating from base pattern (0-100%)
  • reverse: probability of reversing (0-100%)
  • stutter: probability of stutter (with random volume/pitch ramps) (0-100%)
  • pitch: probability of pitch up (0-100%)
  • trunc: probability of truncation (0-100%)
  • half: probability of slow down (0-100%)
  • reverb: probability of adding reverb tail to kick/snare (0-100%)
  • stretch: probability of stretching audio (0-100%)
  • kick: probability of snapping a kick to down beat (0-100%)
  • snare: probability of snapping a snare to down beat (0-100%)
  • kick db: volume of added kick in dB (-96-0 dB)
  • snare db: volume of added snare in dB (-96-0 dB))

all the resulting audio files are automatically put into the ~/dust/audio/makebreakbeat folder.

notes

this script generates beats slowly. to get around this I suggest generating short beats (8-16 beats) continuously (beats continue to play when generating).

run on any linux/mac computer

you don’t need norns to run this script. simply install lua, sox and aubioonset on your computer. (for mac this might involve using brew install aubio-tools sox lua5.3). (for linux this involves doing apt install aubio-tools sox lua5.3). then clone the repo and run:

git clone https://github.com/schollz/makebreakbeat
cd makebreakbeat/lib
./dnb.lua -o 174_3.wav -b 64 -i amen_resampled.wav -trunc 0 -stutter 30 -kick 10 -deviation 10 --snare 10 --reverse 10 --pitch 10 --kick-mix -6 --snare-mix -6 --reverb 5 --stretch 1 --half 1 --trunc 10 --tempo 174 --input-tempo 174 --bassline

Install

install with

;install https://github.com/schollz/makebreakbeat

once you start the script for the first time it will install aubio and sox (~5 MB total).

60 Likes

I will never stop to thank you for your commitment to the script cause :smile:, I bet this give you a lot of happiness and it gives us true happiness for sure.

And, when i see an app like that (eg. Amen, Beets…), which give me the chance to make break beats and stuttering, I’m always so excited as I started making electronic music to achieve that kind of style, even if with Norns I started knowing the “looper wave” and started thinking a lil bit more in these terms.

Which differences this script has compared to Amen for example? I’m asking this before trying the app of course, so the question is more related to your “needs” of making it.
I loved the concept of Amen and the fact that I can use a controller like grid which I love, but I never been able to use it perfectly in sync or quantized to my movements actually.
As always, my hopes for a grid UI are big, but right now, I’m going to install this beauty!

Thanks again!

6 Likes

Looks great! another thing to add to my list of breakcore tools that I never actually manage to make any music with haha

6 Likes

to be honest I just wanted to play with sox and see if I could challenge myself to make generative music out of that little tool. I ended up with dnb.lua which can generate breakbeats and even dnb-style basslines. it was fun little project but since I mainly use norns for music stuff I figured I’d put it into a norns script so I can easily access it.

but on another level - this script using “sox” which (mainly) manipulates audio files vs amen which uses SuperCollider that mainly manipulates audio streams. in practice it was easier to implement some cool things using files versus streams. for example: adding reverb to a sound and then reversing it. this is hard to do in SuperCollider (you’d have to render it to a buffer in between, somehow) but its very easy to do with a file-based tool like sox.

5 Likes

Ok, this make sense, I don’t know Sox at all actually, but it’s very clear what you told me.

Talking again about a grid interface (which is clearly my personal obsession) watching the demo, i think is correct to think about this eventuality as redundant, as it seems more like a super nice generative tool to create stuttering loops with a touch of a button ahah…

1 Like

This looks really cool, but I’m getting an issue where the progress bar doesn’t move at all. Maiden just says ‘resetting’ over and over again. I tried reinstalling and power cycling a few times, but no dice. Anyone got any ideas?

1 Like

can you capture the maiden output when you first turn it on? it might be getting stuck adding some dependencies.

also whats norns? (fates/gray box/ shield)?

1 Like

I had the same issue, updated my norns (or actually fates) to the latest version, and now it works. The beats are amazing, yet another gem @infinitedigits! Can’t wait to try it with my own loops…

4 Likes

I’m running on a Fates. Norns is up to date.
I just did a reinstall and reboot and got these results…

First it worked with the supplied amen_resampled.wav Yay!
Then I tried a different wav file and got a syntax error that I think has to do with the parenthesis in the file name.
Then I tried a different file and got some sox Fails and AUBIO errors.

pset >> write: /home/we/dust/data/makebreakbeat/makebreakbeat-01.pset
lua /home/we/dust/code/makebreakbeat/lib/dnb.lua --no-logo --snare-file /home/we/dust/code/makebreakbeat/lib/snare.wav --kick-file /home/we/dust/code/makebreakbeat/lib/kick.wav  -t 175 -b 9 -o /home/we/dust/audio/makebreakbeat/175_1.wav  -i /home/we/dust/audio/makebreakbeat/amen_resampled.wav --deviation 10 --reverse 10 --stutter 20 --pitch 5 --trunc 2 --half 1 --reverb 5 --stretch 2 --kick 50 --snare 20 --snare-mix  -6 --kick-mix  -6 &
running command!
found 14 onsets
resetting
filename: /tmp/breaktemp-a9hP6gU5.wav
sample rate: 48000
channels: 2
tempo: 177 bpm
resetting
generated 9 beats into '/home/we/dust/audio/makebreakbeat/175_1.wav' @ 175 bpm
resetting
resetting
resetting
resetting
resetting
resetting
pset >> write: /home/we/dust/data/makebreakbeat/makebreakbeat-01.pset
lua /home/we/dust/code/makebreakbeat/lib/dnb.lua --no-logo --snare-file /home/we/dust/code/makebreakbeat/lib/snare.wav --kick-file /home/we/dust/code/makebreakbeat/lib/kick.wav  -t 175 -b 9 -o /home/we/dust/audio/makebreakbeat/175_3.wav  -i /home/we/dust/audio/makebreakbeat/5th Dimension - Rainmaker (part1).wav --deviation 10 --reverse 10 --stutter 20 --pitch 5 --trunc 2 --half 1 --reverb 5 --stretch 2 --kick 50 --snare 20 --snare-mix  -6 --kick-mix  -6 &
sh: 1: Syntax error: "(" unexpected
running command!
resetting
resetting
resetting
resetting
pset >> write: /home/we/dust/data/makebreakbeat/makebreakbeat-01.pset
lua /home/we/dust/code/makebreakbeat/lib/dnb.lua --no-logo --snare-file /home/we/dust/code/makebreakbeat/lib/snare.wav --kick-file /home/we/dust/code/makebreakbeat/lib/kick.wav  -t 175 -b 9 -o /home/we/dust/audio/makebreakbeat/175_3.wav  -i /home/we/dust/audio/makebreakbeat/20th Century - Hot Pants.wav --deviation 10 --reverse 10 --stutter 20 --pitch 5 --trunc 2 --half 1 --reverb 5 --stretch 2 --kick 50 --snare 20 --snare-mix  -6 --kick-mix  -6 &
running command!
sox FAIL formats: can't open input file `/home/we/dust/audio/makebreakbeat/20th': No such file or directory
sox FAIL formats: can't open input file `/home/we/dust/audio/makebreakbeat/20th': No such file or directory
sox FAIL formats: can't open input file `/home/we/dust/audio/makebreakbeat/20th': No such file or directory
AUBIO ERROR: source_sndfile: Failed opening /tmp/breaktemp-gSVYWgHI.wav (System error : No such file or directory.)
AUBIO ERROR: source_wavread: Failed opening /tmp/breaktemp-gSVYWgHI.wav (No such file or directory)
Error: could not open input file /tmp/breaktemp-gSVYWgHI.wav
lua: /home/we/dust/code/makebreakbeat/lib/dnb.lua:33: attempt to perform arithmetic on local 'number' (a nil value)
stack traceback:
	/home/we/dust/code/makebreakbeat/lib/dnb.lua:33: in function </home/we/dust/code/makebreakbeat/lib/dnb.lua:29>
	(tail call): ?
	/home/we/dust/code/makebreakbeat/lib/dnb.lua:398: in function 'new'
	/home/we/dust/code/makebreakbeat/lib/dnb.lua:986: in main chunk
	[C]: ?
resetting
resetting

I also found that I can get the amen sample working again if I re-select it and delete breaktemp-progress from /tmp.

Fuuuuuuuuck. This script is so cool!

2 Likes

Daaaaaamn this gives me a wild idea of making a plugin or extension for the ranger file manager (written in python) where it can “preview” audio files by having Aubio analyze and “chop” it into relevant slices and then use SoX to scrub/navigate through the slices… and then trim/process any interesting bits into a new file… and … and

Crap this gives me ideas! Thanks for sharing :smiley:

Edit: holy crap this might be a big deal Aubio and youtube_dl play nicely together, which could mean that needing to actually download files in order to look for interesting slices might just be obsolete for me aubio : /20171004-1234_online_songs.html

5 Likes

Many thanks as always! Can’t wait to put some non-drum samples into it =]

2 Likes

whooops! yeah that looks to be a bug. glad you figured it out, I can put a fix on that.

that sounds very cool…like file ranger as a daw :slight_smile: aubioonsets gives really pretty good onset detection and once they are split into little units it gives a lot of interesting ways to play.

what I really like about sox though is its ability to splice audio. it allows you to specify a “leeway” which is used with a “wave similarity comparison” to best determine the best place to join:

      length1   excess
    -----------><--->
    _________   :   :  _________________
             \  :   : :\     ‘
              \ :   : : \     ‘
               \:   : :  \     ‘
                *   : :   * - - *
                 \  : :   :\     ‘
                  \ : :   : \     ‘
    _______________\: :   :  \_____‘____
                      :   :   :     :
                      <--->   <----->
                      excess  leeway

not only that, but it will crossfade the two clips (the “excess”) so it can very easily make great “cuts”. this is basically the basis of makebreakbeat.

happy to shoot around ideas if you have. I’ve been digging into sox a lot so its at the forefront of my head right now lol.

this can give some wild things. here’s the Michael Jackson one I made:

13 Likes

Nice! I also discovered that the other issue I was having was being caused by spaces in the file names of the samples I was using. Not sure if that is just a limitation or not.

1 Like

sounds like a typical annoyance with unix file systems, it’ll try to read each individual word as a new file and it causes weird error messages.

2 Likes

looks and sounds great but am getting this error in maiden:

Summary

script clear

script load: /home/we/dust/code/makebreakbeat/makebreakbeat.lua

script run

loading engine: Makebreakbeat

reading PMAP /home/we/dust/data/makebreakbeat/makebreakbeat.pmap

m.read: /home/we/dust/data/makebreakbeat/makebreakbeat.pmap not read.

Engine.register_commands; count: 5

___ engine commands ___

amp f

load_track s

lpf f

lpfqr f

tozero

___ polls ___

amp_in_l

amp_in_r

amp_out_l

amp_out_r

cpu_avg

cpu_peak

pitch_in_l

pitch_in_r

script init

resetting

pset >> read: /home/we/dust/data/makebreakbeat/makebreakbeat-01.pset

E

:

Failed to fetch https://mirrors.switch.ca/raspbian/raspbian/pool/main/libg/libgsm/libgsm1_1.0.13-4_armhf.deb server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

E

: Failed to fetch https://mirrors.switch.ca/raspbian/raspbian/pool/main/o/opencore-amr/libopencore-amrwb0_0.1.3-2.1_armhf.deb server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/w/wavpack/libwavpack1_5.0.0-2+deb9u2_armhf.deb 404 Not Found [IP: 2a00:1098:0:80:1000:75:0:3 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

resetting

resetting

resetting

resetting

resetting

resetting

resetting

resetting

resetting

resetting

resetting

resetting

resetting

1 Like

what kind of norns are you on? (fates/grey box/shield)?

Shield #200323 w sw upd 220129

1 Like

can you try running

os.execute("sudo apt-get update")

through maiden and try again?

edit: and if that doesn’t work - I just built sox that is portable and should work on any norns. you can install it using this command from maiden:

os.execute("cd /tmp && wget https://github.com/schollz/makebreakbeat/releases/download/v0.1.0/sox && chmod +x sox && sudo mv sox /usr/local/bin/")

Ok. did the sudo apt-get and had this response:

Summary

new script

matron

supercollider

os.execute(“sudo apt-get update”)

Get:1 Index of /raspbian stretch InRelease [15.0 kB]

Get:2 Index of /debian stretch InRelease [25.3 kB]

Ign:3 https://package.monome.org stretch InRelease

Get:4 Index of /raspbian stretch/main armhf Packages [11.7 MB]

Err:5 https://package.monome.org stretch Release

server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

Get:6 Index of /debian stretch/main armhf Packages [192 kB]

Get:7 Index of /debian stretch/ui armhf Packages [44.6 kB]

Reading package lists…

E

: The repository ‘https://package.monome.org stretch Release’ does no longer have a Release file.

nil exit 100

then did the second command and got this at the end:

Summary

100%

10.8M

=0.4s

2022-03-05 20:50:13 (6.46 MB/s) - ‘sox’ saved [2638064/2638064]

true exit 0

Restarted and got this again

Summary

resetting

resetting

script clear

script clear

lua:

/home/we/norns/lua/core/clock.lua:59: bad argument #1 to ‘resume’ (thread expected)

stack traceback:

[C]: in function ‘coroutine.resume’

/home/we/norns/lua/core/clock.lua:59: in function ‘core/clock.resume’

lua: /home/we/norns/lua/core/clock.lua:59: bad argument #1 to ‘resume’ (thread expected)

stack traceback:

[C]: in function ‘coroutine.resume’

/home/we/norns/lua/core/clock.lua:59: in function ‘core/clock.resume’

script clear

script load: /home/we/dust/code/makebreakbeat/makebreakbeat.lua

script run

loading engine: Makebreakbeat

reading PMAP /home/we/dust/data/makebreakbeat/makebreakbeat.pmap

m.read: /home/we/dust/data/makebreakbeat/makebreakbeat.pmap not read.

Engine.register_commands; count: 5

___ engine commands ___

amp f

load_track s

lpf f

lpfqr f

tozero

___ polls ___

amp_in_l

amp_in_r

amp_out_l

amp_out_r

cpu_avg

cpu_peak

pitch_in_l

pitch_in_r

script init

resetting

pset >> read: /home/we/dust/data/makebreakbeat/makebreakbeat-01.pset

resetting
resetting

Should I try and remove the pset? Thought maybe it was because no Amen installed, but did that
again and still loops back into resetting, resetting etc. Will admit that have been having off behaviour with the Shield since the last system update, probably Knob Goblins.

1 Like

I pretty much the exact same results just now :slight_smile:

1 Like