Skip to content

Instantly share code, notes, and snippets.

View nischalshrestha's full-sized avatar
👋
Haven't been open sourcing but will be back soon!

Nischal Shrestha nischalshrestha

👋
Haven't been open sourcing but will be back soon!
View GitHub Profile
@nischalshrestha
nischalshrestha / horror.rb
Last active July 11, 2020 07:35
Sonic Pi Horror
# lfo for sines
lfo0 = (range 0, 2, 0.25).mirror
lfo1 = (range 0, 1, 0.025).mirror
# lfo for panning
lfo2 = (range -1, 1, 0.125).mirror
# lfos for bd_haus (dark-side of the beat)
lfo3 = (range 0.25, 0.5, 0.025).mirror
lfo4 = (range 0.5, 3, 0.125).mirror
# let's get wonky with it! slow, slow, slow steps
lfo5 = (range 1, 8, 0.005).mirror
@nischalshrestha
nischalshrestha / get_raw_chunks.R
Last active September 9, 2020 23:41
Raw knitr chunks (inside hook context)
# test file
sample_chunk <- "
```{r hello, testing=as.logical(1), another=1 + 1}
1 + 1
```"
file = "sample.Rmd"
writeLines(sample_chunk, con = file)
foo_hook <- function(before, options, envir) {
# note: this returns raw knitr chunks in list format
# has attribute of "chunk_opts"
@nischalshrestha
nischalshrestha / weird.R
Created July 23, 2020 02:09
R scrambled argument order
library(rlang)
fun <- function(x = 3, y, z = 1) {
paste(x, y, z)
}
# default arguments and regular argument order can be scrambled
# yet produce the same call
@nischalshrestha
nischalshrestha / coffeecookiecrumble.rb
Last active September 12, 2020 04:30
Electronic disco beat
#| electro-disco (4/4)
use_bpm 100
note_value = 0.5 # eighth notes
beats = 8
# beat on/off patterns
hh = spread(8, beats) # hit every beat
sn = spread(2, beats).rotate(-2) # hit 2nd and 4th beat
b = spread(1, beats) # hit 1st and 2nd beat
bd1 = spread(1, 4) * 2 # custom for bass drum
bd2 = spread(1, 8 * 2).rotate(1) # custom for bass drum
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
body {
padding: 10px;
}
@nischalshrestha
nischalshrestha / night_owl.rb
Created February 27, 2021 19:03
Night owl midi jam
# "night owl" jam
# sonic pi version: v3.2.1
with_fx :reverb, room: 1 do
live_loop :midi_piano do
use_real_time
note, velocity = sync "/midi:midi_fighter_64:0:3/note_on"
with_fx :flanger, wave: 0, decay: 0, delay: 0, max_delay: 0 do
synth :pretty_bell, note: note - 12
synth :pluck, note: note - 12, attack: 0, coef: -0.5, sustain: 0, amp: (velocity / 127.0)
synth :pluck, note: note, attack: 0, coef: 0.1, sustain: 0, amp: (velocity / 127.0)
@nischalshrestha
nischalshrestha / conjuring.rb
Created May 31, 2021 06:11
Conjuring Sonic Pi
##| THE CONJURING sound...
live_loop :conjuring do
amp = 1
with_fx :reverb, room: 0.8, mix: 0.8 do
with_fx :lpf, cutoff: 0 do
with_fx :pitch_shift, pitch_dis: 0.002 do
with_synth :saw do
play :e1, amp: amp, attack: 0, sustain: 0.5, release: 1
play :e1, amp: amp, attack: 0.25, sustain: 0.5, release: 1
play :ds1, amp: amp, attack: 0.25, sustain: 0.5, release: 1
@nischalshrestha
nischalshrestha / infinite_space.rb
Last active November 27, 2022 03:45
Sonic Pi tune
# Infinite Space
with_fx :reverb, room: 1, damp: 1 do
with_fx :tremolo, wave: 1, phase: 0.09 do
level = 3
with_fx :gverb, room: 300, damp: 1, ref_level: 0, release: level + 1 do
live_loop :guit do
with_fx :lpf, cutoff: 0 do
vol = 0.25
with_fx :flanger, feedback: 0, phase: 0.8, depth: 4 do
@nischalshrestha
nischalshrestha / THX_logo.rb
Last active December 13, 2022 06:03
Sonic Pi
##################
# THX logo sound #
##################
# THX revealed their sound logo here: https://twitter.com/THX/status/1000077588415447040/photo/1
# beginning random notes in the 200-400Hz
# you can play around with how many intervels you want in the
# 200 to 400hz range, I found 20 to be nice
@nischalshrestha
nischalshrestha / 1.rb
Last active January 31, 2023 15:50
Sonic Pi: Making music with code!
##| You can play notes, chords, scales Oh my!
##| Midi notes
play 64
##| Or with more human-friendly note names :<letter><octave>
##| play :c2
##| play has attack, decay, sustain, release parameters to shape the sound
##| play :c, attack: 1, decay: 0.5, sustain: 2, release: 0.1