«Binaural Beats Experiment» by axl99

on 06 Feb'16 15:44 in experimentalscience

An experimental setup to create files of binaural beats attuned to human brainwave frequencies.

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
s.boot;
(
// see this for explanation: https://en.wikipedia.org/wiki/Binaural_beats

// Wikipedia says binaural beats occur only below 1500hz of the primary frequency and with 
// differences of frequencies of under 40hz

~delta = 1; // 0.5 - 2. deep sleep, unsconsciousness
~theta = 5.5; // 4 - 7. Meditative, drowsy, sleeping. Memory, spatial learning
~mu = 9; // 9 - 11. associated with voluntary movement
~alpha = 10; // 7.5 - 12.5. Relaxed states of mind
~beta1 = 14; // 12.5 - 16. Normal waking consciousness
~beta2 = 18; // 16.5 - 20.
~beta3 = 24; // 20.5 - 28
~gamma = 35; // 32 - 100. Visual awareness, transcendental mental states

// extra bonus vibrations:
~schumann1 = 7.83;
~schumann2 = 14.3;
~schumann3 = 20.8;
~schumann4 = 27.3;
~schumann5 = 33.8;


// the sound synth
SynthDef(\brainwave, {|prime = 200, diff = 10, fade = 15, primetime = 20, difftime = 30, level= 0.4, gate = 1|
	var freqtransition = VarLag.kr(prime, primetime, 0, \lin);
	var links = SinOsc.ar(freqtransition);
	var rechts = SinOsc.ar(freqtransition - VarLag.kr(diff, difftime, 0, \lin));
	var env = EnvGen.kr(Env.asr(fade, level, fade), gate, doneAction:2);
	Out.ar(0, [links, rechts] * env);
}).add;
)

a = Synth(\brainwave, [\prime, 200, \diff, ~alpha]);

a.set(\fade, 20) // set fade out time. The synth is automatically released when faded out

a.set(\primetime, 40); // set transition time for primary frequency changes

a.set(\difftime, 20); // set transition time for arriving at binaural beat target frequencies

a.set(\prime, 100); // set to your favorite freqency.

a.set(\diff, ~beta1) // set the desired brainwave frequency ;-)

a.release; // fade out and release the synth

// here's my 'piece'. It starts at alpha and after 2 minutes slowly goes up to gamma

// uncomment the following and choose a path for the resulting file
// s.prepareForRecord('/Users/axel/Desktop/binaural.aiff')

// now manipulate and run this routine to create a supercharged extra brainwave powered experience 4 free.
(
fork {
	s.record;
	1.wait;
	a = Synth(\brainwave, [\prime, 125.28, \diff, ~alpha]);
	160.wait;
	a.set(\difftime, ~gamma);
	60.wait;
	a.set(\prime, 167.04);
	30.wait;
	a.release;
	16.wait;
	s.stopRecording;
};
)
raw 2274 chars (focus & ctrl+a+c to copy)
reception
comments
maszkowicz user 07 Oct'18 11:25

Thank you for your inspiring code