aboutsummaryrefslogtreecommitdiff
path: root/sonics/instrument_sineblips.udo
blob: e14064c9c7a4487952d0b444de7674535cb53001 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef UDO_FNMI_SINEBLIP
#define UDO_FNMI_SINEBLIP ##
/*
	Stochastic sequenced sine blip instrument
	Slim excerpt for Partial Emergence

	This file is part of the SONICS UDO collection by Richard Knight 2021
		License: GPL-2.0-or-later
		http://1bpm.net
*/

#include "sonics/bussing.udo"
#include "sonics/sequencing_melodic.udo"


/*
	Randomised sine blip playback internal instrument
*/
instr _fnmi_sineblip
	Sbus = p4
	inote = mel_randomnote:i() + 12
	if (random(0, 1) > 0.5) then
		inote += 12
	endif

	if (random(0, 1) > 0.5) then
		inote += 12
	endif

	if (random(0, 1) > 0.5) then
		inote += 12
	endif

	if (random(0, 1) > 0.99) then
		inote += 1
	endif
	ibasefreq = cpsmidinn(inote)
	ifreqL = ibasefreq + random(-5, 5)
	ifreqR = ibasefreq + random(-5, 5)
	iampL = random(0.5, 1)
	iampR = random(0.5, 1)
	aL oscil iampL, ifreqL
	aR oscil iampR, ifreqR

	if (random(0, 1) > 0.5) then
		kamp line 1, p3, 0
	else
		kamp linseg 1, p3*0.9, 1, p3*0.1, 0
	endif
	bus_mix(Sbus, aL*0.3*kamp, aR*0.3*kamp)
endin


/*
	Randomised sine blip playback scheduler
*/
instr fnmi_sineblips
	if (p4 == 0) then
		Sbus = "main"
	else
		Sbus = p4
	endif

	inum = random(1, 8)
	iqtime = i(gkseq_quartertime)
	itimeindex = random(0, 8)
	index = 0
	while (index < inum) do
		itime = seq_swingtime:i(iqtime * itimeindex, itimeindex)
		schedule "_fnmi_sineblip", itime, random(0.05, 0.1), Sbus
		itimeindex += random(1, 4)
		index += 1
	od
	xtratim iqtime * itimeindex
endin

#end