musicality 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +27 -1
  3. data/README.md +153 -10
  4. data/bin/collidify +102 -0
  5. data/bin/lilify +57 -29
  6. data/bin/midify +64 -24
  7. data/bin/musicality +39 -0
  8. data/examples/composition/auto_counterpoint.rb +4 -5
  9. data/examples/composition/part_generator.rb +8 -2
  10. data/examples/composition/scale_exercise.rb +1 -1
  11. data/examples/notation/notes.rb +27 -0
  12. data/examples/notation/parts.rb +51 -0
  13. data/examples/notation/scores.rb +38 -0
  14. data/examples/notation/twinkle.rb +34 -0
  15. data/examples/notation/twinkle.score +33 -0
  16. data/lib/musicality.rb +46 -11
  17. data/lib/musicality/composition/dsl/score_dsl.rb +2 -2
  18. data/lib/musicality/composition/dsl/score_methods.rb +10 -7
  19. data/lib/musicality/notation/conversion/change_conversion.rb +1 -1
  20. data/lib/musicality/notation/conversion/note_time_converter.rb +6 -23
  21. data/lib/musicality/notation/conversion/score_conversion.rb +15 -15
  22. data/lib/musicality/notation/conversion/score_converter.rb +50 -67
  23. data/lib/musicality/notation/model/articulations.rb +3 -2
  24. data/lib/musicality/notation/model/change.rb +15 -6
  25. data/lib/musicality/notation/model/dynamics.rb +11 -8
  26. data/lib/musicality/notation/model/instrument.rb +61 -0
  27. data/lib/musicality/notation/model/instruments.rb +111 -0
  28. data/lib/musicality/notation/model/key.rb +137 -0
  29. data/lib/musicality/notation/model/keys.rb +37 -0
  30. data/lib/musicality/notation/model/link.rb +6 -19
  31. data/lib/musicality/notation/model/mark.rb +43 -0
  32. data/lib/musicality/notation/model/marks.rb +11 -0
  33. data/lib/musicality/notation/model/meter.rb +4 -0
  34. data/lib/musicality/notation/model/note.rb +42 -28
  35. data/lib/musicality/notation/model/part.rb +18 -5
  36. data/lib/musicality/notation/model/pitch.rb +13 -4
  37. data/lib/musicality/notation/model/score.rb +104 -66
  38. data/lib/musicality/notation/model/symbols.rb +16 -11
  39. data/lib/musicality/notation/parsing/articulation_parsing.rb +38 -38
  40. data/lib/musicality/notation/parsing/articulation_parsing.treetop +14 -14
  41. data/lib/musicality/notation/parsing/link_parsing.rb +6 -6
  42. data/lib/musicality/notation/parsing/link_parsing.treetop +3 -3
  43. data/lib/musicality/notation/parsing/mark_parsing.rb +138 -0
  44. data/lib/musicality/notation/parsing/mark_parsing.treetop +31 -0
  45. data/lib/musicality/notation/parsing/note_node.rb +19 -12
  46. data/lib/musicality/notation/parsing/note_parsing.rb +218 -87
  47. data/lib/musicality/notation/parsing/note_parsing.treetop +9 -5
  48. data/lib/musicality/notation/parsing/numbers/nonnegative_integer_parsing.rb +7 -2
  49. data/lib/musicality/notation/parsing/numbers/nonnegative_integer_parsing.treetop +1 -1
  50. data/lib/musicality/notation/parsing/numbers/positive_integer_parsing.rb +6 -4
  51. data/lib/musicality/notation/parsing/numbers/positive_integer_parsing.treetop +1 -1
  52. data/lib/musicality/notation/util/function.rb +41 -18
  53. data/lib/musicality/packable.rb +156 -0
  54. data/lib/musicality/performance/conversion/glissando_converter.rb +2 -2
  55. data/lib/musicality/performance/conversion/note_sequence_extractor.rb +223 -70
  56. data/lib/musicality/performance/conversion/portamento_converter.rb +5 -2
  57. data/lib/musicality/performance/conversion/score_collator.rb +70 -64
  58. data/lib/musicality/performance/midi/midi_events.rb +3 -3
  59. data/lib/musicality/performance/midi/midi_settings.rb +127 -0
  60. data/lib/musicality/performance/midi/midi_util.rb +8 -2
  61. data/lib/musicality/performance/midi/part_sequencer.rb +19 -18
  62. data/lib/musicality/performance/midi/score_sequencer.rb +13 -9
  63. data/lib/musicality/performance/midi/score_sequencing.rb +5 -5
  64. data/lib/musicality/performance/model/attack.rb +8 -0
  65. data/lib/musicality/performance/model/duration_functions.rb +23 -0
  66. data/lib/musicality/performance/model/note_sequence.rb +52 -95
  67. data/lib/musicality/performance/model/separation.rb +10 -0
  68. data/lib/musicality/performance/supercollider/add_actions.rb +13 -0
  69. data/lib/musicality/performance/supercollider/bundle.rb +18 -0
  70. data/lib/musicality/performance/supercollider/conductor.rb +125 -0
  71. data/lib/musicality/performance/supercollider/group.rb +71 -0
  72. data/lib/musicality/performance/supercollider/message.rb +26 -0
  73. data/lib/musicality/performance/supercollider/node.rb +122 -0
  74. data/lib/musicality/performance/supercollider/performer.rb +123 -0
  75. data/lib/musicality/performance/supercollider/score_conducting.rb +17 -0
  76. data/lib/musicality/performance/supercollider/server.rb +8 -0
  77. data/lib/musicality/performance/supercollider/synth.rb +43 -0
  78. data/lib/musicality/performance/supercollider/synthdef.rb +57 -0
  79. data/lib/musicality/performance/supercollider/synthdef_settings.rb +23 -0
  80. data/lib/musicality/performance/supercollider/synthdefs.rb +1654 -0
  81. data/lib/musicality/{composition/model/pitch_class.rb → pitch_class.rb} +1 -1
  82. data/lib/musicality/{composition/model/pitch_classes.rb → pitch_classes.rb} +9 -9
  83. data/lib/musicality/printing/lilypond/clef.rb +12 -0
  84. data/lib/musicality/printing/lilypond/key_engraving.rb +9 -0
  85. data/lib/musicality/printing/lilypond/lilypond_settings.rb +105 -0
  86. data/lib/musicality/printing/lilypond/meter_engraving.rb +1 -1
  87. data/lib/musicality/printing/lilypond/note_engraving.rb +112 -30
  88. data/lib/musicality/printing/lilypond/part_engraver.rb +114 -3
  89. data/lib/musicality/printing/lilypond/pitch_class_engraving.rb +22 -0
  90. data/lib/musicality/printing/lilypond/pitch_engraving.rb +2 -15
  91. data/lib/musicality/printing/lilypond/score_engraver.rb +44 -73
  92. data/lib/musicality/printing/lilypond/score_engraving.rb +3 -3
  93. data/lib/musicality/project/create_tasks.rb +31 -0
  94. data/lib/musicality/project/file_cleaner.rb +19 -0
  95. data/lib/musicality/project/file_raker.rb +107 -0
  96. data/lib/musicality/project/load_config.rb +43 -0
  97. data/lib/musicality/project/project.rb +64 -0
  98. data/lib/musicality/version.rb +1 -1
  99. data/musicality.gemspec +3 -0
  100. data/spec/composition/util/random_sampler_spec.rb +1 -1
  101. data/spec/notation/conversion/measure_note_map_spec.rb +1 -1
  102. data/spec/notation/conversion/note_time_converter_spec.rb +5 -85
  103. data/spec/notation/conversion/score_conversion_spec.rb +6 -41
  104. data/spec/notation/conversion/score_converter_spec.rb +19 -137
  105. data/spec/notation/model/change_spec.rb +55 -0
  106. data/spec/notation/model/key_spec.rb +171 -0
  107. data/spec/notation/model/link_spec.rb +34 -5
  108. data/spec/notation/model/meter_spec.rb +15 -0
  109. data/spec/notation/model/note_spec.rb +33 -27
  110. data/spec/notation/model/part_spec.rb +53 -4
  111. data/spec/notation/model/pitch_spec.rb +15 -0
  112. data/spec/notation/model/score_spec.rb +64 -72
  113. data/spec/notation/parsing/link_nodes_spec.rb +3 -3
  114. data/spec/notation/parsing/link_parsing_spec.rb +6 -6
  115. data/spec/notation/parsing/note_node_spec.rb +34 -9
  116. data/spec/notation/parsing/note_parsing_spec.rb +11 -9
  117. data/spec/notation/parsing/numbers/nonnegative_integer_spec.rb +4 -0
  118. data/spec/notation/parsing/pitch_node_spec.rb +0 -1
  119. data/spec/notation/util/value_computer_spec.rb +2 -2
  120. data/spec/performance/conversion/glissando_converter_spec.rb +9 -9
  121. data/spec/performance/conversion/note_sequence_extractor_spec.rb +48 -53
  122. data/spec/performance/conversion/portamento_converter_spec.rb +11 -9
  123. data/spec/performance/conversion/score_collator_spec.rb +59 -63
  124. data/spec/performance/midi/midi_util_spec.rb +22 -8
  125. data/spec/performance/midi/part_sequencer_spec.rb +2 -2
  126. data/spec/performance/midi/score_sequencer_spec.rb +12 -10
  127. data/spec/performance/midi/score_sequencing_spec.rb +2 -2
  128. data/spec/performance/model/note_sequence_spec.rb +41 -134
  129. data/spec/printing/note_engraving_spec.rb +204 -0
  130. data/spec/printing/score_engraver_spec.rb +40 -0
  131. data/spec/spec_helper.rb +1 -0
  132. metadata +69 -23
  133. data/examples/notation/hip.rb +0 -32
  134. data/examples/notation/missed_connection.rb +0 -26
  135. data/examples/notation/song1.rb +0 -33
  136. data/examples/notation/song2.rb +0 -32
  137. data/lib/musicality/notation/model/links.rb +0 -11
  138. data/lib/musicality/notation/packing/change_packing.rb +0 -56
  139. data/lib/musicality/notation/packing/part_packing.rb +0 -31
  140. data/lib/musicality/notation/packing/score_packing.rb +0 -123
  141. data/lib/musicality/performance/model/note_attacks.rb +0 -19
  142. data/lib/musicality/performance/util/note_linker.rb +0 -28
  143. data/spec/notation/packing/change_packing_spec.rb +0 -304
  144. data/spec/notation/packing/part_packing_spec.rb +0 -66
  145. data/spec/notation/packing/score_packing_spec.rb +0 -255
  146. data/spec/performance/util/note_linker_spec.rb +0 -68
@@ -0,0 +1,26 @@
1
+ module Musicality
2
+ module SuperCollider
3
+
4
+ class Message
5
+ attr_reader :address, :args
6
+ def initialize address, *args
7
+ @address = address
8
+ @args = args
9
+ end
10
+
11
+ def to_sclang
12
+ arg_strs = @args.map do |arg|
13
+ case arg
14
+ when Symbol, String
15
+ "\"#{arg.to_s}\""
16
+ else
17
+ arg.to_s
18
+ end
19
+ end
20
+
21
+ "[\"#{@address}\", #{arg_strs.join(", ")}]"
22
+ end
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,122 @@
1
+ module Musicality
2
+ module SuperCollider
3
+
4
+ class Node
5
+ def self.next_id
6
+ @@next_id += 1
7
+ end
8
+
9
+ def self.reset_id_counter
10
+ @@next_id = 999
11
+ end
12
+ reset_id_counter
13
+
14
+ attr_reader :id, :group, :server, :running, :freed
15
+
16
+ def initialize server, group
17
+ raise ArgumentError unless (server.is_a?(Server) || server.nil?)
18
+ raise ArgumentError unless (group.is_a?(Group) || group.nil?)
19
+ @server, @group = server, group
20
+ @id = Node.next_id
21
+ @freed, @running = false, true
22
+ @queue = []
23
+ end
24
+
25
+ def send_msg msg
26
+ if @server.nil?
27
+ @queue.push msg
28
+ else
29
+ @server.send_msg(msg)
30
+ end
31
+ end
32
+
33
+ def bundle_queue time
34
+ Bundle.new(time, *@queue.shift(@queue.size))
35
+ end
36
+
37
+ # def recv_msg
38
+ # @server.recv_msg
39
+ # end
40
+
41
+ # def wait_for_msg expected_response_addr
42
+ # @server.wait_for_msg(expected_response_addr)
43
+ # end
44
+
45
+ def free
46
+ @group, @running, freed = nil, false, true
47
+ send_msg(Message.new('/n_free', id))
48
+ end
49
+
50
+ def start
51
+ run(true)
52
+ end
53
+
54
+ def stop
55
+ run(false)
56
+ end
57
+
58
+ def set args = {}
59
+ send_msg(Message.new('/n_set', @id, *args.to_a.flatten))
60
+ end
61
+
62
+ def setn args = {}
63
+ ary = args.map {|idx_or_name, vals| [ idx_or_name, vals.size, vals ]}.flatten
64
+ send_msg(Message.new('/n_setn', @id, *ary))
65
+ end
66
+
67
+ def fill idx_or_name, value, n
68
+ send_msg(OSC:Message.new('/n_fill', @id, idx_or_name, n, value))
69
+ end
70
+
71
+ # def map
72
+ # end
73
+
74
+ # def mapn
75
+ # end
76
+
77
+ # def mapa
78
+ # end
79
+
80
+ # def mapan
81
+ # end
82
+
83
+ def before node
84
+ @group = node.group
85
+ send_msg(Message.new( '/n_before', @id, node.id))
86
+ end
87
+
88
+ def after node
89
+ @group = node.group
90
+ send_msg(Message.new( '/n_after', @id, node.id))
91
+ end
92
+
93
+ # def query
94
+ # notifying = @server.notifying
95
+ # unless notifying
96
+ # @server.start_notification
97
+ # end
98
+ # send_msg(OSC::Message.new('/n_query', @id))
99
+ # info = @server.await_notification '/n_info'
100
+ # if notifying
101
+ # @server.stop_notification
102
+ # end
103
+ # info
104
+ # end
105
+
106
+ def trace
107
+ send_msg(Message.new( '/n_trace', @id))
108
+ end
109
+
110
+ # def order
111
+ # end
112
+
113
+ private
114
+
115
+ def run flag
116
+ @running = flag
117
+ send_msg(Message.new( '/n_run', @id, flag ? 1 : 0))
118
+ end
119
+ end
120
+
121
+ end
122
+ end
@@ -0,0 +1,123 @@
1
+ module Musicality
2
+ module SuperCollider
3
+
4
+ class Performer
5
+ MASTER_AUDIO_BUS = 0
6
+
7
+ attr_reader :part, :settings
8
+ def initialize part
9
+ @settings = part.synthdef_settings || SynthDefs::DEFAULT.settings
10
+ @part = part
11
+ unless @settings.synthdef.params.has_key?(:out)
12
+ raise ArgumentError "SynthDef #{@settings.synthdef} does not have :out param"
13
+ end
14
+ @takes_freq = @settings.synthdef.params.has_key? :freq
15
+ @takes_gate = @settings.synthdef.params.has_key? :gate
16
+ end
17
+
18
+ def bundles parent_group: nil, aux_audio_bus: 16, volume_control_bus: 0, lead_time: 0.1
19
+ raise ArgumentError, "Lead time #{lead_time} is not positive" unless lead_time > 0.0
20
+ bundles = []
21
+
22
+ group = create_part_group parent_group, bundles
23
+ set_start_volume volume_control_bus, bundles
24
+ add_volume_control group, aux_audio_bus, volume_control_bus, lead_time, bundles
25
+ add_volume_changes volume_control_bus, lead_time, bundles
26
+ add_part_notes group, aux_audio_bus, lead_time, bundles
27
+
28
+ bundles
29
+ end
30
+
31
+ private
32
+
33
+ def create_part_group parent_group, bundles
34
+ group = Group.tail(parent_group)
35
+ bundles.push group.bundle_queue(0.0)
36
+ return group
37
+ end
38
+
39
+ def set_start_volume volume_control_bus, bundles
40
+ # set start volume
41
+ start_volume_msg = Message.new('/c_set', volume_control_bus, part.start_dynamic)
42
+ bundles.push Bundle.new(0.0, start_volume_msg)
43
+ end
44
+
45
+ def add_volume_control group, aux_audio_bus, volume_control_bus, lead_time, bundles
46
+ # limit overall part output volume from local to master audio bus
47
+ vol_control = Synth.tail(group, SynthDefs::VOLUME_CONTROL.name,
48
+ :in => aux_audio_bus,
49
+ :out => MASTER_AUDIO_BUS,
50
+ :control => volume_control_bus)
51
+ bundles.push vol_control.bundle_queue(lead_time / 2.0)
52
+ end
53
+
54
+ def add_volume_changes volume_control_bus, lead_time, bundles
55
+ # change part volume
56
+ part.dynamic_changes.each do |offset,change|
57
+ case change
58
+ when Change::Immediate
59
+ change_volume_msg = Message.new('/c_set', volume_control_bus, change.end_value)
60
+ bundles.push Bundle.new(offset+lead_time, change_volume_msg)
61
+ when Change::Gradual
62
+ raise ArgumentError, "absolute gradual changes are not supported yet" if change.absolute?
63
+
64
+ vc = Synth.head(group, SynthDefs::VOLUME_CHANGE.name,
65
+ :vol_bus => volume_control_bus,
66
+ :vol => change.end_value,
67
+ :dur => change.duration)
68
+ bundles.push vc.bundle_queue(offset+lead_time)
69
+
70
+ vc.free
71
+ bundles.push vc.bundle_queue(offset+lead_time+change.duration)
72
+ else
73
+ raise ArgumentError, "Unknown change type for #{change}"
74
+ end
75
+ end
76
+ end
77
+
78
+ def add_part_notes group, aux_audio_bus, lead_time, bundles
79
+ # play part notes
80
+ NoteSequenceExtractor.new(part.notes).extract_sequences.each do |note_seq|
81
+ offsets = note_seq.offsets
82
+ freqs = note_seq.elements.map {|el| el.pitch.freq }
83
+ attacks = note_seq.elements.map {|el| el.attack }
84
+
85
+ args = setup_args(aux_audio_bus, freqs[0])
86
+ s = Synth.head(group, @settings.synthdef.name, args)
87
+ bundles.push s.bundle_queue(offsets[0]+lead_time)
88
+
89
+ # change voice synth pitch
90
+ (1...offsets.size).each do |i|
91
+ offset = offsets[i]
92
+ if attacks[i] == Attack::NONE
93
+ s.set(:freq => freqs[i])
94
+ bundles.push s.bundle_queue(offset+lead_time)
95
+ else
96
+ if @takes_gate
97
+ s.set(:gate => 0)
98
+ bundles.push s.bundle_queue(offset)
99
+ end
100
+
101
+ args = setup_args(aux_audio_bus, freqs[i])
102
+ s = Synth.head(group, @settings.synthdef.name, args)
103
+ bundles.push s.bundle_queue(offset+lead_time)
104
+ end
105
+ end
106
+
107
+ if @takes_gate
108
+ s.set(:gate => 0)
109
+ bundles.push s.bundle_queue(note_seq.stop+lead_time)
110
+ end
111
+ end
112
+ end
113
+
114
+ def setup_args out, freq
115
+ args = { :out => out }
116
+ args[:freq] = freq if @takes_freq
117
+ args[:gate] = 1 if @takes_gate
118
+ @settings.args.merge(args)
119
+ end
120
+ end
121
+
122
+ end
123
+ end
@@ -0,0 +1,17 @@
1
+ module Musicality
2
+
3
+ class Score
4
+ class Timed < Score
5
+ def to_osc base_fpath, **kwargs
6
+ SuperCollider::Conductor.new(self).perform(base_fpath, **kwargs)
7
+ end
8
+ end
9
+
10
+ class Tempo < Score
11
+ def to_osc tempo_sample_rate, base_fpath, **kwargs
12
+ to_timed(tempo_sample_rate).to_osc(base_fpath, **kwargs)
13
+ end
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,8 @@
1
+ module Musicality
2
+ module SuperCollider
3
+
4
+ class Server
5
+ end
6
+
7
+ end
8
+ end
@@ -0,0 +1,43 @@
1
+ module Musicality
2
+ module SuperCollider
3
+
4
+ class Synth < Node
5
+ attr_reader :id, :group, :server, :running, :freed
6
+
7
+
8
+ def initialize server, group, synthdef_name, add_action, target_id, args
9
+ raise ArgumentError unless ADD_ACTIONS.include?(add_action)
10
+ super server, group
11
+ send_msg(Message.new('/s_new', synthdef_name, id,
12
+ add_action, target_id, *args.to_a.flatten))
13
+ end
14
+
15
+ def self.after target, synthdef_name, args = {}
16
+ raise ArgumentError unless target.is_a?(Node)
17
+ new target.server, target.group, synthdef_name, ADD_AFTER, target.id, args
18
+ end
19
+
20
+ def self.before target, synthdef_name, args = {}
21
+ raise ArgumentError unless target.is_a?(Node)
22
+ new target.server, target.group, synthdef_name, ADD_BEFORE, target.id, args
23
+ end
24
+
25
+ def self.head target, synthdef_name, args = {}
26
+ raise ArgumentError unless target.is_a?(Group)
27
+ new target.server, target, synthdef_name, ADD_HEAD, target.id, args
28
+ end
29
+
30
+ def self.tail target, synthdef_name, args = {}
31
+ raise ArgumentError unless target.is_a?(Group)
32
+ new target.server, target, synthdef_name, ADD_TAIL, target.id, args
33
+ end
34
+
35
+ def self.replace target, synthdef_name, args = {}
36
+ raise ArgumentError unless target.is_a?(Node)
37
+ new target.server, target.group, synthdef_name, ADD_REPLACE, target.id, args
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,57 @@
1
+ module Musicality
2
+ module SuperCollider
3
+
4
+ class SynthDef
5
+ include Packable
6
+
7
+ attr_reader :name, :params, :body, :credit, :source
8
+ def initialize name: "", params: {}, body: "", credit: "", source: ""
9
+ raise ArgumentError if name.empty?
10
+ raise ArgumentError if body.empty?
11
+
12
+ @name, @params, @body = name, params, body
13
+ @credit, @source = credit, source
14
+ end
15
+
16
+ def to_sclang
17
+ params_str = "|" + @params.map {|k,v| v.nil? ? k.to_s : "#{k} = #{v}" }.join(", ") + "|"
18
+ output = "SynthDef(\"#{@name}\", {" + params_str + "\n" + @body + "#{"\n" unless @body[-1] == "\n"}\}"
19
+
20
+ unless (@credit.empty? && @source.empty?)
21
+ metadata_str = ", metadata: (\n"
22
+ unless @credit.empty?
23
+ metadata_str += " credit: \"#{@credit}\",\n"
24
+ end
25
+ unless @source.empty?
26
+ metadata_str += " source: \"#{@source}\"\n"
27
+ end
28
+ metadata_str += ")\n"
29
+ output += metadata_str
30
+ end
31
+
32
+ output += ").writeDefFile;"
33
+ end
34
+
35
+ class Settings
36
+ include Packable
37
+
38
+ attr_reader :synthdef, :args
39
+ def initialize synthdef, args = {}
40
+ @synthdef, @args = synthdef, args
41
+ end
42
+ end
43
+
44
+ def settings args = {}
45
+ Settings.new(self, args)
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ class Part
52
+ def synthdef_settings
53
+ find_settings(SuperCollider::SynthDef::Settings)
54
+ end
55
+ end
56
+
57
+ end
@@ -0,0 +1,23 @@
1
+ module Musicality
2
+ module SuperCollider
3
+
4
+ class SynthdefSettings
5
+ include Packable
6
+ attr_reader :name, :args
7
+
8
+ def initialize name, args={}
9
+ @name, @args = name, args
10
+ end
11
+ end
12
+
13
+ DEFAULT_SYNTHDEF_SETTINGS = DEFAULT_SYNTHDEF.settings
14
+
15
+ end
16
+
17
+ class Part
18
+ def synthdef_settings
19
+ find_settings(SuperCollider::SynthdefSettings)
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,1654 @@
1
+ module Musicality
2
+ module SuperCollider
3
+ module SynthDefs
4
+
5
+ VOLUME_CONTROL = SynthDef.new(name: "volume_control", params: { :in => nil, :out => nil, :control => nil },
6
+ body: " Out.ar(out, In.ar(in) * In.kr(control));",
7
+ credit: "James Tunnell",
8
+ )
9
+
10
+ VOLUME_CHANGE = SynthDef.new(name: "volume_change", params: { :vol_bus => nil, :vol => nil, :dur => nil },
11
+ body: " Out.kr(vol_bus, Line.kr(In.kr(vol_bus), vol, dur));",
12
+ credit: "James Tunnell",
13
+ )
14
+
15
+ KICK808 = SynthDef.new(name: "kick808", params: { :out => 0 },
16
+ body: <<-SCLANG,
17
+ var sig = LPF.ar(Ringz.ar(Impulse.ar(0), 60, 1), 500);
18
+ var cmp = CompanderD.ar(sig, -20.dbamp, 1, 0.3, 0.003, 0.08);
19
+
20
+ cmp = cmp * (10.dbamp);
21
+ Out.ar(out, cmp.dup);
22
+ SCLANG
23
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014"
24
+ )
25
+
26
+ KICK2 = SynthDef.new(name: "kick2", params: { :out => 0 },
27
+ body: <<-SCLANG,
28
+ var env0, env1, env1m, sig;
29
+
30
+ env0 = EnvGen.ar(
31
+ Env([0.5, 1, 0.5, 0], [0.005, 0.06, 0.26], [-4, -2, -4]), doneAction:2
32
+ );
33
+ env1 = EnvGen.ar(Env([110, 59, 29], [0.005, 0.29], [-4, -5]));
34
+ env1m = env1.midicps;
35
+
36
+ sig = LFPulse.ar(env1m, 0, 0.5, 1, -0.5);
37
+ sig = sig + WhiteNoise.ar(1);
38
+ sig = LPF.ar(sig, env1m * 1.5, env0);
39
+ sig = sig + SinOsc.ar(env1m, 0.5, env0);
40
+
41
+ sig = sig * 1.2;
42
+ sig = sig.clip2(1);
43
+
44
+ Out.ar(out, sig.dup * 0.1);
45
+ SCLANG
46
+ credit: "Reformatted for the Roundhouse Synth Design course from 08091500Acid309 by otophilia from SuperCollider/examples folder",
47
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
48
+ )
49
+
50
+ SNARE1 = SynthDef.new(name: "snare1", params: { :out => 0, :amp => 0.8 },
51
+ body: <<-SCLANG,
52
+ var env0, env1, env2, env1m, oscs, noise, sig;
53
+
54
+ env0 = EnvGen.ar(Env([0.5, 1, 0.5, 0], [0.005, 0.03, 0.10], [-4, -2, -4]));
55
+ env1 = EnvGen.ar(Env([110, 60, 49], [0.005, 0.1], [-4, -5]));
56
+ env1m = env1.midicps;
57
+ env2 = EnvGen.ar(Env([1, 0.4, 0], [0.05, 0.13], [-2, -2]), doneAction:2);
58
+
59
+ oscs = LFPulse.ar(env1m, 0, 0.5, 1, -0.5) +
60
+ LFPulse.ar(env1m * 1.6, 0, 0.5, 0.5, -0.25);
61
+ oscs = LPF.ar(oscs, env1m * 1.2, env0);
62
+ oscs = oscs + SinOsc.ar(env1m, 0.8, env0);
63
+
64
+ noise = WhiteNoise.ar(0.2);
65
+ noise = HPF.ar(noise, 200, 2);
66
+ noise = BPF.ar(noise, 6900, 0.6, 3) + noise;
67
+ noise = noise * env2;
68
+
69
+ sig = oscs + noise;
70
+ sig = sig.clip2(1) * amp;
71
+
72
+ Out.ar(out, sig.dup);
73
+ SCLANG
74
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
75
+ )
76
+
77
+ CLAP1 = SynthDef.new(name: "clap1", params: { :out => 0, :amp => 0.5 },
78
+ body: <<-SCLANG,
79
+ var env1, env2, sig, noise1, noise2;
80
+
81
+ env1 = EnvGen.ar(Env(
82
+ [0, 1, 0, 1, 0, 1, 0, 1, 0],
83
+ [0.001, 0.013, 0, 0.01, 0, 0.01, 0, 0.03],
84
+ [0, -3, 0, -3, 0, -3, 0, -4]
85
+ ));
86
+ env2 = EnvGen.ar(Env([0, 1, 0], [0.02, 0.3], [0, -4]), doneAction:2);
87
+
88
+ noise1 = WhiteNoise.ar(env1);
89
+ noise1 = HPF.ar(noise1, 600);
90
+ noise1 = BPF.ar(noise1, 2000, 3);
91
+
92
+ noise2 = WhiteNoise.ar(env2);
93
+ noise2 = HPF.ar(noise2, 1000);
94
+ noise2 = BPF.ar(noise2, 1200, 0.7, 0.7);
95
+
96
+ sig = noise1 + noise2;
97
+ sig = sig * 2;
98
+ sig = sig.softclip * amp;
99
+
100
+ Out.ar(out, sig.dup);
101
+ SCLANG
102
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
103
+ )
104
+
105
+ AXEL = DEFAULT = SynthDef.new(name: "axel", params: { :freq => 440, :lpfreq => 12000, :rq => 0.2, :gate => 1, :out => 0 },
106
+ body: <<-SCLANG,
107
+ var chorus = LFNoise2.ar(1).range(0.99, 1.01);
108
+ var saw1 = LFSaw.ar(freq * chorus, 0, 0.1);
109
+ var saw2 = LFSaw.ar((freq.cpsmidi - 0.1).midicps * chorus, 0, 0.1);
110
+ var tri = LFTri.ar(freq * chorus, 0, 0.1);
111
+ var mix = Mix([saw1, saw2, tri]);
112
+ var lpf = RLPF.ar(mix, lpfreq, rq);
113
+ var env = EnvGen.ar(Env.adsr(0.3, 0.6, 0.5, 0.25), gate, doneAction: 2);
114
+ Out.ar(out, Pan2.ar(lpf * env, 0));
115
+ SCLANG
116
+ credit: "By Arthur Carabott, based on Sound on Sound article",
117
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
118
+ )
119
+
120
+ BRASS = SynthDef.new(name: "brass", params: { :freq => 220, :detune1 => 1, :detune2 => 0.5, :ffreq => 12000, :rq => 0.4,
121
+ :pan => 0, :gate => 1, :out => 0 },
122
+ body: <<-SCLANG,
123
+ var sig, env, fenv;
124
+
125
+ sig = Mix([freq, freq - detune1, freq + detune2, freq / 2].collect {|freq|
126
+ LFSaw.ar(freq);
127
+ });
128
+ fenv = EnvGen.kr(Env([ffreq, 0], [0.06], \\sin));
129
+ sig = RHPF.ar(sig, fenv, rq);
130
+ env = EnvGen.ar(Env.asr(0.01, 1, 0.1), gate, doneAction:2);
131
+
132
+ Out.ar(out, Pan2.ar(sig * env * 0.2, pan));
133
+ SCLANG
134
+ credit: "Based on Sound on Sound Synth Secrets Part 25 by Arthur Carabott",
135
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
136
+ )
137
+
138
+ RES = SynthDef.new(name: "res", params: { :out => 0, :gate => 1, :freq => 440, :ffreq => 1500 },
139
+ body: <<-SCLANG,
140
+ var aEnv, osc, flt;
141
+ aEnv = EnvGen.kr(Env.perc(0, 0.7), gate, doneAction: 2);
142
+ osc = Mix([Saw.ar(freq), Pulse.ar(freq / 2, 0.5)]);
143
+ flt = RLPF.ar(osc, ffreq, 0.1, aEnv);
144
+ Out.ar(out, Pan2.ar(flt, 0));
145
+ SCLANG
146
+ credit: "From the Kraftwerk 'Spacelab' example in SuperCollider/examples by jy",
147
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
148
+ )
149
+
150
+ POLY2 = SynthDef.new(name: "poly2", params: { :out => 0, :gate => 1, :freq => 440 },
151
+ body: <<-SCLANG,
152
+ var aEnv, fEnv, osc1, osc2, flt;
153
+ aEnv = EnvGen.kr(Env.asr(0.2, 1, 0.1), gate, doneAction: 2);
154
+ fEnv = EnvGen.kr(Env.asr(7, 1, 0.2), levelScale: 12000);
155
+ osc1 = Pulse.ar(freq * [1, 1.007], LFCub.kr(2, 0, 0.3, 0.5));
156
+ osc2 = Pulse.ar(freq / 2, 0.3);
157
+ flt = RLPF.ar(osc1 + osc2, fEnv, 0.9, aEnv);
158
+ Out.ar(out, flt);
159
+ SCLANG
160
+ credit: "From the Kraftwerk 'Spacelab' example in SuperCollider/examples by jy",
161
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
162
+ )
163
+
164
+ SOLO = SynthDef.new(name: "solo", params: { :out => 0, :gate => 1, :freq => 440 },
165
+ body: <<-SCLANG,
166
+ var aEnv, fEnv, osc, flt;
167
+ aEnv = EnvGen.kr(Env.asr(0.2, 1, 2), gate);
168
+ fEnv = EnvGen.kr(Env.adsr(0.4, 1.2, 0.7, 2), gate, 800);
169
+ osc = Saw.ar(Lag.kr(freq, 0.1) * [1, 1.005]);
170
+ flt = LPF.ar(osc, fEnv + 600, aEnv);
171
+ Out.ar(out, flt);
172
+ SCLANG
173
+ credit: "From the Kraftwerk 'Spacelab' example in SuperCollider/examples by jy",
174
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
175
+ )
176
+
177
+ STRING = SynthDef.new(name: "string", params: { :out => 0, :gate => 1, :freq => 1000 },
178
+ body: <<-SCLANG,
179
+ var aEnv, osc, flt;
180
+ aEnv = EnvGen.kr(Env.asr(0.2, 1, 0.5), gate, doneAction: 2);
181
+ osc = Saw.ar([
182
+ LFCub.kr(0.3, Rand(0, 1), freq * 0.003, freq),
183
+ freq,
184
+ LFCub.kr(0.7, Rand(0, 1), freq * 0.001, freq)
185
+ ]);
186
+ flt = LPF.ar(osc, 1500, aEnv);
187
+ Out.ar(out, flt);
188
+ SCLANG
189
+ credit: "From the Kraftwerk 'Spacelab' example in SuperCollider/examples by jy",
190
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
191
+ )
192
+
193
+ BASS4 = SynthDef.new(name: "bass4", params: { :out => 0, :gate => 1, :freq => 440 },
194
+ body: <<-SCLANG,
195
+ var aEnv, fEnv, osc, flt;
196
+ aEnv = EnvGen.kr(Env.asr(0, 1, 1), gate, doneAction: 2);
197
+ fEnv = EnvGen.kr(Env.perc(0, 3), levelScale: 6000);
198
+ osc = Mix([Saw.ar(freq * [1, 1.005]), Pulse.ar(freq / 2, 0.5)]);
199
+ flt = LPF.ar(osc, fEnv + 100, aEnv);
200
+ Out.ar(out, flt);
201
+ SCLANG
202
+ credit: "From the Kraftwerk 'Spacelab' example in SuperCollider/examples by jy",
203
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
204
+ )
205
+
206
+ //
207
+
208
+ ESM = SynthDef.new(name: "esm", params: { :freq => 440, :mix => 0.5, :glide => 0, :cutoff => 20000, :rq => 1, :fdec => 0, :fint => 1,
209
+ :vel => 1, :fvel => 1, :t_gate => 1, :vdec => 1, :vvel => 0, :od => 0, :mul => 0.1, :pan => 0, :out => 0 },
210
+ body: <<-SCLANG,
211
+ var sig, saw, rect, fstart, fenv, vstart, venv;
212
+
213
+ freq = freq.lag(glide);
214
+
215
+ // oscillators
216
+ saw = LFSaw.ar(freq, 0, 1);
217
+ rect = LFPulse.ar(freq, 0, 0.5, 1);
218
+ sig = Mix([saw * (1-mix), rect * mix]);
219
+
220
+ // filter
221
+ fstart = vel.linlin(0, fvel, 0, fint).linexp(0, 1, cutoff, 20000);
222
+ fenv = EnvGen.kr(Env([fstart, fstart, cutoff], [0.001, fdec]), t_gate);
223
+ sig = LPF.ar(sig, fenv, rq);
224
+
225
+ // volume env
226
+ vstart = vel.linlin(0, vvel.max(10e-1), 0, 1);
227
+ venv = EnvGen.ar(Env([vstart, vstart, 0], [0.01, vdec], \cub), t_gate);
228
+ sig = sig * venv;
229
+
230
+ // distortion
231
+ sig = sig * od.linlin(0, 1, 1, 100).clip2(mul);
232
+
233
+ Out.ar(out, Pan2.ar(sig, pan));
234
+ SCLANG
235
+ credit: "Emulations of two synths from Logic Pro X, by Arthur Carabott",
236
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
237
+ )
238
+
239
+ ROCKIT = SynthDef.new(name: "rockit", params: { :freq => 440, :detune => 2, :gate => 1, :out => 0 },
240
+ body: <<-SCLANG,
241
+ var osc1, osc2, pwm, mix, env;
242
+
243
+ // envelope for pulse width
244
+ pwm = EnvGen.kr(Env([0, 0.5, 0], [0.1, 0.3], ['lin', -1]));
245
+
246
+ // two oscillators, slightly detuned
247
+ osc1 = LFPulse.ar(freq, 0, pwm);
248
+ osc2 = LFPulse.ar(freq - detune, 0, pwm);
249
+
250
+ // mixdown oscillators
251
+ mix = Mix([osc1, osc2]);
252
+
253
+ // amplitude envelope
254
+ env = EnvGen.ar(Env.asr(0.001, 1, 0.05), gate, doneAction:2);
255
+ mix = mix * env;
256
+
257
+ Out.ar(out, Pan2.ar(mix, 0));
258
+ SCLANG
259
+ credit: "From the 'Emulating Video Game Sounds' recipe, page 78 of 'Steal This Sound' by Mitchell Sigman, Adapted by Arthur Carabott",
260
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
261
+ )
262
+
263
+ SNARE2 = SynthDef.new(name: "snare2", params: { :sfreq => 1500, :out => 0 },
264
+ body: <<-SCLANG,
265
+ var tri = Mix([LFTri.ar([111, 175, 224])]) * 0.5;
266
+ var sine = Mix([SinOsc.ar([330, 180])]) * 0.5;
267
+ var env = EnvGen.ar(Env.perc(0.01, 0.2), doneAction:2);
268
+ var snares = WhiteNoise.ar(1);
269
+ var snareEnv = EnvGen.ar(Env.perc(0.01, 0.2));
270
+
271
+ snares = HPF.ar(snares, sfreq);
272
+ snares = snares * snareEnv;
273
+
274
+ Out.ar(out, Mix([tri, sine, snares]) * env);
275
+ SCLANG
276
+ credit: "Based on Sound on Sound Synth Secrets 35, by Arthur Carabott",
277
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
278
+ )
279
+
280
+ PROPHET5_STRINGS = SynthDef.new(name: "prophet5pwmstrings", params: { :out => 0, :freq => 440, :amp => 0.8,
281
+ :gate => 1, :lforate => 3, :lfowidth => 0.1, :cutoff => 12000, :rq => 0.5, :pan => 0.0 },
282
+ body: <<-SCLANG,
283
+ var lfo, pulse, filter, env;
284
+
285
+ lfo = LFTri.kr(lforate*[1,1.01],Rand(0,2.0)!2);
286
+ pulse = Pulse.ar(freq*[1,1.01],lfo*lfowidth+0.5);
287
+ filter = RLPF.ar(pulse,cutoff,rq);
288
+ env = EnvGen.ar(Env.adsr(0.01,0.0,1.0,0.5),gate,doneAction:2);
289
+
290
+ Out.ar(out,Pan2.ar(Mix(filter)*env*amp*0.5,pan));
291
+ SCLANG
292
+ credit: <<-EOS,
293
+ Sound recipes from:
294
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
295
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
296
+ under GNU GPL 3 as per SuperCollider license
297
+ EOS
298
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
299
+ )
300
+
301
+ OSC_WOBBLE = SynthDef.new(name: "singleoscillatorwobble", params: { :out => 0, :freq => 440, :amp => 0.8,
302
+ :gate => 1, :lforate => 10, :lfowidth => 0.5, :cutoff => 12000, :rq => 0.5, :pan => 0.0 },
303
+ body: <<-SCLANG,
304
+ var lfo, pulse, filter, env;
305
+
306
+ lfo = LFTri.kr(lforate,Rand(0,2.0)!2);
307
+ pulse = Pulse.ar(freq*(1.0+(lfowidth*lfo)),0.5);
308
+ filter = RLPF.ar(pulse,cutoff,rq);
309
+ env = EnvGen.ar(Env.adsr(0.01,0.0,1.0,0.5),gate,doneAction:2);
310
+
311
+ Out.ar(out,Pan2.ar(filter*env*amp*0.5,pan));
312
+ SCLANG
313
+ credit: <<-EOS,
314
+ Sound recipes from:
315
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
316
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
317
+ under GNU GPL 3 as per SuperCollider license
318
+ EOS
319
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
320
+ )
321
+
322
+ TRI_BELLS = SynthDef.new(name:"trianglewavebells", params: { :out => 0, :freq => 440, :amp => 0.8, :gate => 1,
323
+ :lforate => 10, :lfowidth => 0.0, :cutoff => 100, :rq => 0.5, :pan => 0.0 },
324
+ body: <<-SCLANG,
325
+ var osc1, osc2, vibrato, filter, env;
326
+
327
+ vibrato = SinOsc.ar(lforate,Rand(0,2.0));
328
+ osc1 = Saw.ar(freq*(1.0+(lfowidth*vibrato)),0.75);
329
+ //Saw a bit rough, possibly slighter smoother:
330
+ //osc1 = DPW4Saw.ar(freq*(1.0+(lfowidth*vibrato)),0.5);
331
+ osc2 = Mix(LFTri.ar((freq.cpsmidi+[11.9,12.1]).midicps));
332
+ //filter = (osc1+(osc2*0.5))*0.5; //no filter version
333
+ filter = RHPF.ar((osc1+(osc2*0.5))*0.5,cutoff,rq);
334
+ env = EnvGen.ar(Env.adsr(0.01,0.1,1.0,0.5),gate,doneAction:2);
335
+
336
+ Out.ar(out,Pan2.ar(filter*env*amp,pan));
337
+ SCLANG
338
+ credit: <<-EOS,
339
+ Sound recipes from:
340
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
341
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
342
+ under GNU GPL 3 as per SuperCollider license
343
+ EOS
344
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
345
+ )
346
+
347
+ LASER_BEAM = SynthDef.new(name: "laserbeam", params: { :out => 0, :freq => 440, :amp => 0.8, :attackTime => 0.04, :gate => 1, :pan => 0.0 },
348
+ body: <<-SCLANG,
349
+ var osc1, freqenv, env;
350
+
351
+ freqenv = EnvGen.ar(Env([4,0.5,1,1],[attackTime,0.01,1.0]));
352
+
353
+ osc1 = LFTri.ar(freq*freqenv);
354
+
355
+ env = EnvGen.ar(Env.adsr(0.01,0.0,1.0,0.1),gate,doneAction:2);
356
+ //no gate, fixed envelope size
357
+ //env = EnvGen.ar(Env([0,1,0.5,0.0],[0.02,0.2,0.1]),doneAction:2);
358
+
359
+ Out.ar(out,Pan2.ar(osc1*env*amp,pan));
360
+ SCLANG
361
+ credit: <<-EOS,
362
+ Sound recipes from:
363
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
364
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
365
+ under GNU GPL 3 as per SuperCollider license
366
+ EOS
367
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
368
+ )
369
+
370
+ MOOG_BASS = SynthDef.new(name: "moogbass", params: { :out => 0, :freq => 440, :amp => 0.8, :gate => 1,
371
+ :cutoff => 1000, :gain => 2.0, :lagamount => 0.01, :pan => 0.0 },
372
+ body: <<-SCLANG,
373
+ var osc, filter, env, filterenv;
374
+
375
+ osc = Mix(VarSaw.ar(freq.lag(lagamount)*[1.0,1.001,2.0],Rand(0.0,1.0)!3,Rand(0.5,0.75)!3,0.33));
376
+ filterenv = EnvGen.ar(Env.adsr(0.2,0.0,1.0,0.2),gate,doneAction:2);
377
+ filter = MoogFF.ar(osc,cutoff*(1.0+(0.5*filterenv)),gain);
378
+ env = EnvGen.ar(Env.adsr(0.001,0.3,0.9,0.2),gate,doneAction:2);
379
+
380
+ Out.ar(out,Pan2.ar((0.7*filter+(0.3*filter.distort))*env*amp*1.5,pan));
381
+ SCLANG
382
+ credit: <<-EOS,
383
+ Sound recipes from:
384
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
385
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
386
+ under GNU GPL 3 as per SuperCollider license
387
+ EOS
388
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
389
+ )
390
+
391
+ MOOG_BASS2 = SynthDef.new(name: "moogbass2", params: { :out => 0, :freq => 440, :amp => 0.8, :gate => 1,
392
+ :attackTime => 0.2, :fenvamount => 0.5, :cutoff => 1000, :gain => 2.0, :pan => 0.0 },
393
+ body: <<-SCLANG,
394
+ var osc, filter, env, filterenv;
395
+
396
+ //alternative: richer source
397
+ osc = Mix(Pulse.ar(freq.lag(0.05)*[1.0,1.001,2.0],Rand(0.45,0.5)!3,0.33));
398
+ filterenv = EnvGen.ar(Env.adsr(attackTime,0.0,1.0,0.2),gate,doneAction:2);
399
+ filter = MoogFF.ar(osc,cutoff*(1.0+(fenvamount*filterenv)),gain);
400
+ env = EnvGen.ar(Env.adsr(0.001,0.3,0.9,0.2),gate,doneAction:2);
401
+
402
+ Out.ar(out,Pan2.ar((0.7*filter+(0.3*filter.distort))*env*amp,pan));
403
+ SCLANG
404
+ credit: <<-EOS,
405
+ Sound recipes from:
406
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
407
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
408
+ under GNU GPL 3 as per SuperCollider license
409
+ EOS
410
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
411
+ )
412
+
413
+ PLASTICKY_STRINGS = SynthDef.new(name: "plastickystrings", params: { :out => 0, :freq => 440, :amp => 0.8, :gate => 1,
414
+ :lforate => 5900, :lfowidth => 0.01, :cutoff => 12000, :rq => 0.5, :pan => 0.0 },
415
+ body: <<-SCLANG,
416
+ var lfo, saw, filter, env;
417
+
418
+ lfo = LFTri.ar(lforate,Rand(0,2.0));
419
+ saw = Saw.ar(freq*(1.0+(lfowidth*lfo)),0.5);
420
+ //filter = BBandPass.ar(saw,freq,4);
421
+ filter = BHiPass.ar(saw,freq,rq); //or using cutoff
422
+ env = EnvGen.ar(Env.adsr(0.4,0.0,1.0,1.0),gate,doneAction:2);
423
+
424
+ Out.ar(out,Pan2.ar(filter*env*amp,pan));
425
+ SCLANG
426
+ credit: <<-EOS,
427
+ Sound recipes from:
428
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
429
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
430
+ under GNU GPL 3 as per SuperCollider license
431
+ EOS
432
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
433
+ )
434
+
435
+ BASS_FOUNDATION = SynthDef.new(name: "bassfoundation", params: { :out => 0, :freq => 440, :amp => 0.8, :gate => 1,
436
+ :cutoff => 1000, :rq => 0.5, :pan => 0.0 },
437
+ body: <<-SCLANG,
438
+ var osc, filter, env, filterenv;
439
+
440
+ osc = Saw.ar(freq);
441
+ filterenv = EnvGen.ar(Env.adsr(0.0,0.5,0.2,0.2),gate,doneAction:2);
442
+ filter = RLPF.ar(osc,cutoff*filterenv+100,rq);
443
+ env = EnvGen.ar(Env.adsr(0.01,0.0,0.9,0.05),gate,doneAction:2);
444
+
445
+ Out.ar(out,Pan2.ar(filter*env*amp*2,pan));
446
+ SCLANG
447
+ credit: <<-EOS,
448
+ Sound recipes from:
449
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
450
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
451
+ under GNU GPL 3 as per SuperCollider license
452
+ EOS
453
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
454
+ )
455
+
456
+ BASS_HIGHEND = SynthDef.new(name: "basshighend", params: { :out => 0, :freq => 440, :amp => 0.8, :gate => 1,
457
+ :cutoff => 3000, :rq => 0.1, :drive => 2.0, :pan => 0.0 },
458
+ body: <<-SCLANG,
459
+ var osc, filter, env, filterenv;
460
+ var ab;
461
+
462
+ //osc = Mix(VarSaw.ar(freq*[0.25,1,1.5],Rand(0.0,1.0)!3,0.9,[0.5,0.4,0.1]));
463
+ osc = Mix(Saw.ar(freq*[0.25,1,1.5],[0.5,0.4,0.1]));
464
+ //osc = Mix(DPW4Saw.ar(freq*[0.25,1,1.5],[0.5,0.4,0.1]));
465
+ filterenv = EnvGen.ar(Env.adsr(0.0,0.5,0.2,0.2),gate,doneAction:2);
466
+ filter = RLPF.ar(osc,cutoff*filterenv+100,rq);
467
+
468
+ //distortion
469
+ //filter = filter.distort.softclip;
470
+
471
+ ab = abs(filter);
472
+ filter = (filter*(ab + drive)/(filter ** 2 + (drive - 1) * ab + 1));
473
+
474
+ //remove low end
475
+ filter = BLowShelf.ar(filter,300,1.0,-12);
476
+ //dip at 1600Hz
477
+ filter = BPeakEQ.ar(filter,1600,1.0,-6);
478
+
479
+ env = EnvGen.ar(Env.adsr(0.01,0.0,0.9,0.05),gate,doneAction:2);
480
+
481
+ Out.ar(out,Pan2.ar(filter*env*amp*2,pan));
482
+ SCLANG
483
+ credit: <<-EOS,
484
+ Sound recipes from:
485
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
486
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
487
+ under GNU GPL 3 as per SuperCollider license
488
+ EOS
489
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
490
+ )
491
+
492
+ WINWOOD_LEAD = SynthDef.new(name: "winwoodlead", params: { :out => 0, :freq => 440, :amp => 0.8, :gate => 1,
493
+ :cutoff => 8000, :rq => 0.8, :lfowidth => 0.01, :lforate => 8, :lagamount => 0.01, :pan => 0.0 },
494
+ body: <<-SCLANG,
495
+ var pulse, filter, env, lfo;
496
+
497
+ lfo = LFTri.kr(lforate,Rand(0,2.0)!2);
498
+ pulse = Mix(Pulse.ar((freq.lag(lagamount))*[1,1.001]*(1.0+(lfowidth*lfo)),[0.2,0.19]))*0.5;
499
+ filter = RLPF.ar(pulse,cutoff,rq);
500
+ //remove low end
501
+ filter = BLowShelf.ar(filter,351,1.0,-9);
502
+ env = EnvGen.ar(Env.adsr(0.01,0.0,0.9,0.05),gate,doneAction:2);
503
+
504
+ Out.ar(out,Pan2.ar(filter*env*amp,pan));
505
+ SCLANG
506
+ credit: <<-EOS,
507
+ Sound recipes from:
508
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
509
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
510
+ under GNU GPL 3 as per SuperCollider license
511
+ EOS
512
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
513
+ )
514
+
515
+ SITUATION_SYNTH = SynthDef.new(name: "situationsynth", params: { :out => 0, :freq => 440, :amp => 0.1, :gate => 1,
516
+ :cutoff => 8000, :rq => 0.8, :lfowidth => 0.001, :lforate => 3.3, :pan => -0.1 },
517
+ body: <<-SCLANG,
518
+ var pulse, filter, env, filterenv, lfo;
519
+
520
+ lfo = LFTri.kr(lforate,Rand(0,2.0)!2);
521
+ pulse = Mix(Pulse.ar((((freq.cpsmidi)+[0,0.14])+(lfo*lfowidth)).midicps,[0.5,0.51]+(lfowidth*lfo)))*0.5;
522
+ filterenv = EnvGen.ar(Env([0.0,1.0,0.3,0.0],[0.005,0.57,0.1],-3));
523
+ filter = RLPF.ar(pulse,100+(filterenv*cutoff),rq);
524
+ env = EnvGen.ar(Env.adsr(0.002,0.57,1.0,0.3),gate,doneAction:2);
525
+
526
+ Out.ar(out,Pan2.ar(filter*env*amp,pan));
527
+ SCLANG
528
+ )
529
+
530
+ RES_SQUARES = SynthDef.new(name: "ressquares", params: { :out => 0, :freq => 440, :amp => 0.1, :gate => 1,
531
+ :cutoff => 8000, :rq => 0.8, :pan => -0.1 },
532
+ body: <<-SCLANG,
533
+ var pulse, filter, env;
534
+
535
+ //2 cents detune for second oscillator
536
+ pulse = Mix(Pulse.ar( ((freq.cpsmidi)+[0,0.02]).midicps, 0.5))*0.5;
537
+ filter = BLowPass.ar(pulse,100+cutoff,rq);
538
+ env = EnvGen.ar(Env.adsr(0.002,0.1,1.0,0.2),gate,doneAction:2);
539
+
540
+ Out.ar(out,Pan2.ar(filter*env*amp,pan));
541
+ SCLANG
542
+ credit: <<-EOS,
543
+ Sound recipes from:
544
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
545
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
546
+ under GNU GPL 3 as per SuperCollider license
547
+ EOS
548
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
549
+ )
550
+
551
+ EIGHTTOEIGHT_KICK = SynthDef.new(name: "eightoeightkick", params: { :out => 0, :freq => 440, :amp => 0.1,
552
+ :ringTime => 10.0, :releaseTime => 1.0, :distortion => 0.1, :pan => -0.1 },
553
+ body: <<-SCLANG,
554
+ var impulse, filter, env;
555
+
556
+ impulse = Impulse.ar(0);
557
+ filter = Ringz.ar(impulse,XLine.ar(freq,60,0.1),ringTime);
558
+ env = EnvGen.ar(Env.perc(0.001,releaseTime),doneAction:2);
559
+ filter = (1.0-distortion)*filter + (distortion*(filter.distort));
560
+
561
+ Out.ar(out,Pan2.ar(filter*env*amp,pan));
562
+ SCLANG
563
+ credit: <<-EOS,
564
+ Sound recipes from:
565
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
566
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
567
+ under GNU GPL 3 as per SuperCollider license
568
+ EOS
569
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
570
+ )
571
+
572
+ TONEWHEEL_TWO = SynthDef.new(name: "tonewheeltwo", params: { :out => 0, :freq => 440, :amp => 0.1, :gate => 1,
573
+ :lforate => 4.85, :lfowidth => 0.1, :cutoff => 5000, :rq => 0.25, :pan => 0.0 },
574
+ body: <<-SCLANG,
575
+ //tone wheel organ emulation via two oscillators pp. 50-51
576
+
577
+ var lfo, pulse, filter, env;
578
+
579
+ lfo = LFTri.kr(lforate*[1,1.01],Rand(0,2.0)!2);
580
+ pulse = Pulse.ar( (((freq*[1,3]).cpsmidi) + (lfo*lfowidth)).midicps,[0.5,0.51],[0.4,0.6]);
581
+ env = EnvGen.ar(Env.adsr(0.0,0.0,1.0,0.1),gate,doneAction:2);
582
+ filter = BLowPass4.ar(pulse,cutoff,rq);
583
+ filter = BPeakEQ.ar(filter,500,1.0,3);
584
+
585
+ Out.ar(out,Pan2.ar(Mix(filter)*env*amp,pan));
586
+ SCLANG
587
+ credit: <<-EOS,
588
+ Sound recipes from:
589
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
590
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
591
+ under GNU GPL 3 as per SuperCollider license
592
+ EOS
593
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
594
+ )
595
+
596
+ EVERYTHING_RHODES = SynthDef.new(name: "everythingrhodes", params: { :out => 0, :freq => 440, :amp => 0.1, :gate => 1,
597
+ :lforate => 1.85, :lfowidth => 0.5, :cutoff => 2000, :rq => 0.2, :pan => 0.0 },
598
+ body: <<-SCLANG,
599
+ var pulse, filter, env;
600
+
601
+ pulse = Pulse.ar(freq*[1,33.5.midiratio],[0.2,0.1],[0.7,0.3]);
602
+ env = EnvGen.ar(Env.adsr(0.0,1.0,0.8,3.0),gate,doneAction:2);
603
+ //keyboard tracking filter cutoff
604
+ filter = BLowPass4.ar(pulse,(cutoff*(env.squared))+200+freq,rq);
605
+
606
+ Out.ar(out,Pan2.ar(Mix(filter)*env*amp,pan));
607
+ SCLANG
608
+ credit: <<-EOS,
609
+ Sound recipes from:
610
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
611
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
612
+ under GNU GPL 3 as per SuperCollider license
613
+ EOS
614
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
615
+ )
616
+
617
+ SPACE_THEREMIN = SynthDef.new(name: "spacetheremin", params: { :out => 0, :freq => 440, :amp => 0.1,
618
+ :gate => 1, :lforate => 6, :lfowidth => 0.5, :cutoff => 4000, :rq => 0.25, :lagTime => 0.1, :pan => 0.0 },
619
+ body: <<-SCLANG,
620
+ var lfo, osc, filter, env;
621
+
622
+ lfo = LFTri.kr(lforate+(LFNoise1.kr(5,0.3,0.3)),Rand(0,2.0));
623
+ osc = Saw.ar((freq.lag(lagTime).cpsmidi+(lfo*lfowidth)).midicps,0.5);
624
+ filter = BLowPass4.ar(osc,cutoff.lag(lagTime*4),rq);
625
+ env = EnvGen.ar(Env.adsr(0.6,0.0,1.0,0.05),gate,doneAction:2);
626
+
627
+ Out.ar(out,Pan2.ar(filter*env*amp.lag(lagTime*4),pan));
628
+ SCLANG
629
+ credit: <<-EOS,
630
+ Sound recipes from:
631
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
632
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
633
+ under GNU GPL 3 as per SuperCollider license
634
+ EOS
635
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
636
+ )
637
+
638
+ FAT_VELOCITY_BASS = SynthDef.new(name: "fatvelocitybass", params: { :out => 0, :freq => 440, :amp => 0.5,
639
+ :gate => 1, :cutoff => 2000, :rq => 0.15, :lagTime => 0.01, :pan => 0.0 },
640
+ body: <<-SCLANG,
641
+ var lfo, osc, filter, env;
642
+
643
+ var basefreq = ((freq.lag(lagTime).cpsmidi)+[0,11.95,31.03]).midicps;
644
+ osc = Saw.ar(basefreq,[0.5,0.4,0.1]); //+PinkNoise.ar(Line.kr(1.0,0,0.03));
645
+ env = EnvGen.ar(Env.adsr(0.01,1.0,1.0,0.25),gate,doneAction:2);
646
+ filter = BLowPass4.ar(osc,100+((amp.squared)*(freq+cutoff)),rq);
647
+
648
+ Out.ar(out,Pan2.ar(Mix(filter)*env*amp*0.8,pan));
649
+ SCLANG
650
+ credit: <<-EOS,
651
+ Sound recipes from:
652
+ Mitchell Sigman (2011) Steal this Sound. Milwaukee, WI: Hal Leonard Books
653
+ adapted for SuperCollider and elaborated by Nick Collins (http://www.sussex.ac.uk/Users/nc81/index.html)
654
+ under GNU GPL 3 as per SuperCollider license
655
+ EOS
656
+ source: "https://github.com/acarabott/roundhouse-synth-design-course-2014",
657
+ )
658
+
659
+
660
+ PMC_ROTALE = SynthDef.new(name: "PMCrotale", params: { :out => 0, :freq => 261, :tone => 3, :art => 1, :amp => 0.8, :pan => 0 },
661
+ body: <<-SCLANG,
662
+ var env, mod, sig;
663
+
664
+ env = Env.perc(0, art);
665
+ mod = 5 + (1/IRand(2, 6));
666
+
667
+ sig = PMOsc.ar(freq, mod*freq,
668
+ pmindex: EnvGen.kr(env, timeScale: art, levelScale: tone),
669
+ mul: EnvGen.kr(env, timeScale: art, levelScale: 0.3));
670
+
671
+ sig = Pan2.ar(sig, pan);
672
+
673
+ sig = sig * EnvGen.kr(env, timeScale: 1.3*art,
674
+ levelScale: Rand(0.1, 0.5), doneAction:2);
675
+ Out.ar(out, sig*amp);
676
+ SCLANG
677
+ source: "From https://github.com/brunoruviaro/SynthDefs-for-Patterns",
678
+ )
679
+
680
+ KICK3 = SynthDef.new(name: "kick3", params: { :out => 0, :punch => 1, :amp => 1 },
681
+ body: <<-SCLANG,
682
+ var freq = EnvGen.kr(Env([400, 66], [0.08], -3)),
683
+ sig = Normalizer.ar(SinOsc.ar(freq, 0.5pi, punch).distort, 1) * amp
684
+ * EnvGen.kr(Env([0, 1, 0.8, 0], [0.01, 0.1, 0.2]), doneAction: 2);
685
+ Out.ar(out, sig ! 2);
686
+ SCLANG
687
+ source: "From https://github.com/brunoruviaro/SynthDefs-for-Patterns",
688
+ )
689
+
690
+ RING_KICK = SynthDef.new(name: "ringkick", params: { :out => 0, :freq => 40, :decay => 0.25, :amp => 1 },
691
+ body: <<-SCLANG,
692
+ var snd;
693
+ snd = Ringz.ar(
694
+ in: LPF.ar(
695
+ in: Impulse.ar(0),
696
+ freq: 1000),
697
+ freq: freq,
698
+ decaytime: decay,
699
+ mul: 7 * amp).tanh.sin*2;
700
+ Out.ar(out, snd!2);
701
+ SCLANG
702
+ source: "From https://github.com/brunoruviaro/SynthDefs-for-Patterns",
703
+ )
704
+
705
+ BASS1 = SynthDef.new(name: "bass1", params: { :out => 0, :freq => 440, :gate => 1, :amp => 0.5, :slideTime => 0.17, :ffreq => 1100, :width => 0.15, :detune => 1.005, :preamp => 4 },
706
+ body: <<-SCLANG,
707
+ var sig, env;
708
+ env = Env.adsr(0.01, 0.3, 0.4, 0.1);
709
+ freq = Lag.kr(freq, slideTime);
710
+ sig = Mix(VarSaw.ar([freq, freq * detune], 0, width, preamp)).distort;
711
+ sig = sig * amp * EnvGen.kr(env, gate, doneAction: 2);
712
+ sig = LPF.ar(sig, ffreq);
713
+ Out.ar(out, sig ! 2)
714
+ SCLANG
715
+ source: "From https://github.com/brunoruviaro/SynthDefs-for-Patterns",
716
+ )
717
+
718
+ KIK = SynthDef.new(name: "kik", params: { :out => 0, :basefreq => 50, :ratio => 7, :sweeptime => 0.05, :preamp => 1, :amp => 1, :decay1 => 0.3, :decay1L => 0.8, :decay2 => 0.15 },
719
+ body: <<-SCLANG,
720
+ var fcurve = EnvGen.kr(Env([basefreq * ratio, basefreq], [sweeptime], \exp)),
721
+ env = EnvGen.kr(Env([1, decay1L, 0], [decay1, decay2], -4), doneAction: 2),
722
+ sig = SinOsc.ar(fcurve, 0.5pi, preamp).distort * env * amp;
723
+ Out.ar(out, sig ! 2)
724
+ SCLANG
725
+ source: "From https://github.com/brunoruviaro/SynthDefs-for-Patterns",
726
+ )
727
+
728
+ KRAFTY_SNR = SynthDef.new(name: "kraftySnr", params: { :out => 0, :amp => 1, :freq => 2000, :rq => 3, :decay => 0.3, :pan => 0 },
729
+ body: <<-SCLANG,
730
+ var sig = PinkNoise.ar(amp),
731
+ env = EnvGen.kr(Env.perc(0.01, decay), doneAction: 2);
732
+ sig = BPF.ar(sig, freq, rq, env);
733
+ Out.ar(out, Pan2.ar(sig, pan))
734
+ SCLANG
735
+ source: "From https://github.com/brunoruviaro/SynthDefs-for-Patterns",
736
+ )
737
+
738
+ SILLY_VOICE = SynthDef.new(name: "sillyVoice", params: { :out => 0, :freq => 220, :amp => 0.5, :vibratoSpeed => 6, :vibratoDepth => 4, :vowel => 0, :att => 0.01, :rel => 0.1, :lag => 1, :gate => 1 },
739
+ body: <<-SCLANG,
740
+ var in, vibrato, env, va, ve, vi, vo, vu, snd;
741
+
742
+ vibrato = SinOsc.kr(vibratoSpeed, mul: vibratoDepth);
743
+ in = Saw.ar(Lag.kr(freq, lag) + vibrato);
744
+ env = EnvGen.kr(Env.asr(att, 1, rel), gate, doneAction: 2);
745
+
746
+ va = BBandPass.ar(
747
+ in: in,
748
+ freq: [ 600, 1040, 2250, 2450, 2750 ],
749
+ bw: [ 0.1, 0.067307692307692, 0.048888888888889, 0.048979591836735, 0.047272727272727 ],
750
+ mul: [ 1, 0.44668359215096, 0.35481338923358, 0.35481338923358, 0.1 ]);
751
+
752
+ ve = BBandPass.ar(
753
+ in: in,
754
+ freq: [ 400, 1620, 2400, 2800, 3100 ] ,
755
+ bw: [ 0.1, 0.049382716049383, 0.041666666666667, 0.042857142857143, 0.038709677419355 ],
756
+ mul: [ 1, 0.25118864315096, 0.35481338923358, 0.25118864315096, 0.12589254117942 ]);
757
+
758
+ vi = BBandPass.ar(
759
+ in: in,
760
+ freq: [ 250, 1750, 2600, 3050, 3340 ] ,
761
+ bw: [ 0.24, 0.051428571428571, 0.038461538461538, 0.039344262295082, 0.035928143712575 ],
762
+ mul: [ 1, 0.031622776601684, 0.15848931924611, 0.079432823472428, 0.03981071705535 ] );
763
+
764
+ vo = BBandPass.ar(
765
+ in: in,
766
+ freq:[ 400, 750, 2400, 2600, 2900 ] ,
767
+ bw: [ 0.1, 0.10666666666667, 0.041666666666667, 0.046153846153846, 0.041379310344828 ],
768
+ mul: [ 1, 0.28183829312645, 0.089125093813375, 0.1, 0.01 ]);
769
+
770
+ vu = BBandPass.ar(
771
+ in: in,
772
+ freq: [ 350, 600, 2400, 2675, 2950 ],
773
+ bw: [ 0.11428571428571, 0.13333333333333, 0.041666666666667, 0.044859813084112, 0.040677966101695 ],
774
+ mul: [ 1, 0.1, 0.025118864315096, 0.03981071705535, 0.015848931924611 ]);
775
+
776
+ snd = SelectX.ar(Lag.kr(vowel, lag), [va, ve, vi, vo, vu]);
777
+ snd = Mix.new(snd);
778
+ Out.ar(out, snd!2 * env * amp);
779
+ SCLANG
780
+ source: "From https://github.com/brunoruviaro/SynthDefs-for-Patterns",
781
+ )
782
+
783
+ PLUCKING = SynthDef.new(name: "plucking", params: { :out => 0, :amp => 0.1, :freq => 440, :decay => 5, :coef => 0.1 },
784
+ body: <<-SCLANG,
785
+ var env, snd;
786
+ env = EnvGen.kr(Env.linen(0, decay, 0), doneAction: 2);
787
+ snd = Pluck.ar(
788
+ in: WhiteNoise.ar(amp),
789
+ trig: Impulse.kr(0),
790
+
791
+ maxdelaytime: 0.1,
792
+ delaytime: freq.reciprocal,
793
+ decaytime: decay,
794
+ coef: coef);
795
+ Out.ar(out, [snd, snd]);
796
+ SCLANG
797
+ source: "From https://github.com/brunoruviaro/SynthDefs-for-Patterns",
798
+ )
799
+
800
+ TRIG_DEMO = SynthDef.new(name: "trig_demo", params: { :out => 0, :freq => 440, :gate => 1, :t_trig => 1 },
801
+ body: <<-SCLANG,
802
+ var env, sig;
803
+ env = Decay2.kr(t_trig, 0.01, 0.1);
804
+ sig = SinOsc.ar(freq, 0, env);
805
+ sig = sig * Linen.kr(gate, 0.01, 0.1, 0.1, doneAction: 2);
806
+ Out.ar(out, sig ! 2)
807
+ SCLANG
808
+ source: "From https://github.com/brunoruviaro/SynthDefs-for-Patterns",
809
+ )
810
+
811
+
812
+ SINE_WLFO = SynthDef.new(name: "sineWlfo", params: { :out => 0, :rate => 0.5, :freqlo => 150, :freqhi => 300, :amp => 0.1 },
813
+ body: <<-SCLANG,
814
+ var sig, lfo, rms;
815
+ lfo = SinOsc.kr(rate).range(freqlo, freqhi);
816
+ sig = SinOsc.ar(lfo);
817
+ sig = sig*amp.dbamp;
818
+ Out.ar(out, sig)
819
+ SCLANG
820
+ source: "From https://github.com/elosine/synthdefs",
821
+ )
822
+
823
+ NOISE_BURST = SynthDef.new(name: "noiseBurst", params: { :out => 0, :rate => 1.0, :atk => 0.03, :decay => 0.75, :amp => 0 },
824
+ body: <<-SCLANG,
825
+ var sig;
826
+ sig = PinkNoise.ar(0.5) * Decay2.ar( Impulse.ar(rate), atk, decay );
827
+ sig = sig*amp.dbamp;
828
+ Out.ar(out, sig)
829
+ SCLANG
830
+ source: "From https://github.com/elosine/synthdefs",
831
+ )
832
+
833
+
834
+ DRUM_KICK = SynthDef.new(name: "drum_kick", params: { :out => 0, :freq => 440, :gate => 1, :amp => 0.8, :source => nil,:pan => 0.0 },
835
+ body: <<-SCLANG,
836
+ var x1, x2, x3;
837
+
838
+ x1 = SinOsc.ar(EnvGen.kr(Env.perc(0.0001, 1.5, 1, -200), gate, 1000, 45, doneAction:2), 1, 1);
839
+ x2 = ((BPF.ar([GrayNoise.ar(6),GrayNoise.ar(6)],EnvGen.kr(Env.perc(0.001, 0.3, 1, -200), gate, 6000, 70), 1.5)).distort * Line.kr(0.3,0,0.1));
840
+ x3 = EnvGen.kr(Env.perc(0.0001, 0.09, amp, 8));
841
+ source = Pan2.ar(x1 + x2 * x3, 0);
842
+ Out.ar(out, source);
843
+ SCLANG
844
+ source: "https://github.com/willieavendano/SC-SynthDefs/blob/master/DrumMachines",
845
+ )
846
+
847
+ CHORD_BASS = SynthDef.new(name: "chord_bass", params: { :out => 0, :amp => 0.5, :sustain => 0.1, :freq => 90, :filtfreq1 => 7000, :filtfreq2 => 1000, :releaseTime => 0.5, :reverb => 0.1,:rq => 0.99 },
848
+ body: <<-SCLANG,
849
+ var env, sound;
850
+ env=EnvGen.ar(Env.perc(releaseTime:releaseTime),doneAction:2);
851
+ sound=FreeVerb.ar(RLPF.ar(LFSaw.ar(freq,0,amp),Line.kr(filtfreq1, filtfreq2,0.1),rq), reverb, 0.2, 0.5);
852
+ Out.ar(out,Pan2.ar(sound*env, 0.0))
853
+ SCLANG
854
+ source: "https://github.com/willieavendano/SC-SynthDefs/blob/master/DrumMachines",
855
+ )
856
+
857
+ MY_BASS = SynthDef.new(name: "my_bass", params: { :out => 0, :amp => 1, :sustain => 0.3, :freq => 90, :filtfreq1 => 7000, :filtfreq2 => 1000, :releaseTime => 0.5, :reverb => 0.3, :rq => 0.99 },
858
+ body: <<-SCLANG,
859
+ var env, sound;
860
+ env=EnvGen.ar(Env.perc(releaseTime:releaseTime),doneAction:2);
861
+ sound=FreeVerb.ar(RLPF.ar(LFTri.ar(freq,0,amp*2),Line.kr(filtfreq1, filtfreq2,0.1),rq) ,reverb, 0.2 ,0.5);
862
+ Out.ar(out,Pan2.ar(sound*env, 0.0))
863
+ SCLANG
864
+ source: "https://github.com/willieavendano/SC-SynthDefs/blob/master/DrumMachines",
865
+ )
866
+
867
+ SOS_SNARE = SynthDef.new(name: "SOSsnare", params: { :out => 0, :decay => 0.12, :drum_mode_level => 0.25, :snare_level => 40, :snare_tightness => 3000, :freq => 405, :amp => 0.8 },
868
+ body: <<-SCLANG,
869
+ var drum_mode_sin_1, drum_mode_sin_2, drum_mode_pmosc, drum_mode_mix,
870
+ drum_mode_env;
871
+ var snare_noise, snare_brf_1, snare_brf_2, snare_brf_3, snare_brf_4,
872
+ snare_reson;
873
+ var snare_env;
874
+ var snare_drum_mix;
875
+
876
+ drum_mode_env = EnvGen.ar(Env.perc(0.005, decay), 1.0, doneAction: 2);
877
+ drum_mode_sin_1 = SinOsc.ar(freq*0.53, 0, drum_mode_env * 0.5);
878
+ drum_mode_sin_2 = SinOsc.ar(freq, 0, drum_mode_env * 0.5);
879
+ drum_mode_pmosc = PMOsc.ar( Saw.ar(freq*0.85), 184, 0.5/1.3, mul: drum_mode_env*5, add: 0);
880
+ drum_mode_mix = Mix.new([drum_mode_sin_1, drum_mode_sin_2, drum_mode_pmosc]) * drum_mode_level;
881
+
882
+ // choose either noise source below
883
+ // snare_noise = Crackle.ar(2.01, 1);
884
+ snare_noise = LFNoise0.ar(20000, 0.1);
885
+ snare_env = EnvGen.ar(Env.perc(0.005, decay, curve:-5), 1.0, doneAction: 2);
886
+ snare_brf_1 = BRF.ar(in: snare_noise, freq: 8000, mul: 0.5, rq: 0.1);
887
+ snare_brf_2 = BRF.ar(in: snare_brf_1, freq: 5000, mul: 0.5, rq: 0.1);
888
+ snare_brf_3 = BRF.ar(in: snare_brf_2, freq: 3600, mul: 0.5, rq: 0.1);
889
+ snare_brf_4 = BRF.ar(in: snare_brf_3, freq: 2000, mul: snare_env, rq: 0.0001);
890
+ snare_reson = Resonz.ar(snare_brf_4, snare_tightness, mul: snare_level) ;
891
+ snare_drum_mix = Mix.new([drum_mode_mix, snare_reson]) * 5 * amp;
892
+ Out.ar(out, [snare_drum_mix, snare_drum_mix])
893
+ SCLANG
894
+ credit: "recipe basically from Gordon Reid
895
+ http://www.soundonsound.com/sos/Mar02/articles/synthsecrets0302.asp
896
+ programmed by Renick Bell, renick_at_gmail.com",
897
+ source: "https://github.com/willieavendano/SC-SynthDefs/blob/master/DrumMachines",
898
+ )
899
+
900
+ CLOSED_HAT = SynthDef.new(name: "closedhat", params: { :out => 0 },
901
+ body: <<-SCLANG,
902
+ var hatosc, hatenv, hatnoise, hatoutput;
903
+
904
+ hatnoise = {LPF.ar(WhiteNoise.ar(1),8000)};
905
+
906
+ hatosc = {HPF.ar(hatnoise,2400)};
907
+ hatenv = {Line.ar(1, 0, 0.1)};
908
+
909
+ hatoutput = (0.5 * hatosc * hatenv);
910
+
911
+ Out.ar(out, Pan2.ar(hatoutput, 0));
912
+ SCLANG
913
+ source: "https://github.com/willieavendano/SC-SynthDefs/blob/master/DrumMachines",
914
+ )
915
+
916
+
917
+ ACID_OTO_309 = SynthDef.new(name: "acid_oto309", params: { :out => 0, :gate => 1, :freq => 440, :amp => 0.1, :pan => 0 },
918
+ body: <<-SCLANG,
919
+ var env1, env2, son, pitch;
920
+ pitch = freq.cpsmidi;
921
+ pitch = Lag.kr(pitch, 0.12 * (1-Trig.kr(gate, 0.001)) * gate);
922
+ env1 = EnvGen.ar(Env.new([0, 1.0, 0, 0], [0.001, 2.0, 0.04], [0, -4, -4], 2), gate, amp);
923
+ env2 = EnvGen.ar(Env.adsr(0.001, 0.8, 0, 0.8, 70, -4), gate);
924
+ son = LFPulse.ar(pitch.midicps, 0.0, 0.51, 2, -1);
925
+
926
+ son = RLPF.ar(son, (pitch + env2).midicps, 0.3);
927
+ son = son * env1;
928
+
929
+ Out.ar(out, Pan2.ar(son, pan));
930
+ SCLANG
931
+ credit: "from 08091500Acid309 by_otophilia",
932
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
933
+ )
934
+
935
+ APAD_MH = SynthDef.new(name: "apad_mh", params: { :freq => 880, :amp => 0.5, :attack => 0.4, :decay => 0.5, :sustain => 0.8, :release => 1.0, :gate => 1, :out => 0 },
936
+ body: <<-SCLANG,
937
+ var env,sig,mod1,mod2,mod3;
938
+ env=EnvGen.kr(Env.adsr(attack,decay,sustain,release),gate,levelScale:amp,doneAction:2);
939
+ mod1=SinOsc.kr(6).range(freq*0.99,freq*1.01);
940
+ mod2=LFNoise2.kr(1).range(0.2,1);
941
+ mod3=SinOsc.kr(rrand(4.0,6.0)).range(0.5,1);
942
+ sig=SinOsc.ar([freq,mod1],0,env).distort;
943
+ sig=sig*mod2*mod3;
944
+ Out.ar(out,sig);
945
+ SCLANG
946
+ credit: "A simple sustained sound with vibrato --Mike Hairston",
947
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
948
+ )
949
+
950
+ CHEAP_PIANO = SynthDef.new(name: "cheappiano", params: { :out => 0, :freq => 440, :amp => 1, :dur => 1, :gate => 1, :pan => 0 },
951
+ body: <<-SCLANG,
952
+ var sig, in, n = 6, max = 0.04, min = 0.01, delay, pitch, detune, hammer;
953
+ freq = freq.cpsmidi;
954
+ hammer = Decay2.ar(Impulse.ar(0.001), 0.008, 0.04, LFNoise2.ar([2000,4000].asSpec.map(amp), 0.25));
955
+ sig = Mix.ar(Array.fill(3, { arg i;
956
+ detune = #[-0.04, 0, 0.03].at(i);
957
+ delay = (1/(freq + detune).midicps);
958
+ CombL.ar(hammer, delay, delay, 50 * amp)
959
+ }) );
960
+
961
+ sig = HPF.ar(sig,50) * EnvGen.ar(Env.perc(0.0001,dur, amp * 4, -1), gate: gate, doneAction:2);
962
+ Out.ar(out, Pan2.ar(sig, pan));
963
+ SCLANG
964
+ credit: "based on something posted 2008-06-17 by jeff, based on an old example by james mcc",
965
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
966
+ )
967
+
968
+ CLAP_OTO_309 = SynthDef.new(name: "clap_oto309", params: { :out => 0, :amp => 0.6, :pan => 0 },
969
+ body: <<-SCLANG,
970
+ var env1, env2, son, noise1, noise2;
971
+
972
+ env1 = EnvGen.ar(Env.new([0, 1, 0, 1, 0, 1, 0, 1, 0], [0.001, 0.013, 0, 0.01, 0, 0.01, 0, 0.03], [0, -3, 0, -3, 0, -3, 0, -4]));
973
+ env2 = EnvGen.ar(Env.new([0, 1, 0], [0.02, 0.3], [0, -4]), doneAction:2);
974
+
975
+ noise1 = WhiteNoise.ar(env1);
976
+ noise1 = HPF.ar(noise1, 600);
977
+ noise1 = BPF.ar(noise1, 2000, 3);
978
+
979
+ noise2 = WhiteNoise.ar(env2);
980
+ noise2 = HPF.ar(noise2, 1000);
981
+ noise2 = BPF.ar(noise2, 1200, 0.7, 0.7);
982
+
983
+ son = noise1 + noise2;
984
+ son = son * 2;
985
+ son = son.softclip * amp;
986
+
987
+ Out.ar(out, Pan2.ar(son, pan));
988
+ SCLANG
989
+ credit: "from 08091500Acid309 by_otophilia",
990
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
991
+ )
992
+
993
+ CS80_LEAD_MH = SynthDef.new(name: "cs80lead_mh", params: { :freq => 880, :amp => 0.5, :att => 0.75, :decay => 0.5,
994
+ :sus => 0.8, :rel => 1.0, :fatt => 0.75, :fdecay => 0.5, :fsus => 0.8, :frel => 1.0, :cutoff => 200, :pan => 0,
995
+ :dtune => 0.002, :vibrate => 4, :vibdepth => 0.015, :gate => 1, :ratio => 1,:out => 0 },
996
+ body: <<-SCLANG,
997
+ var env,fenv,vib,ffreq,sig;
998
+ cutoff=1000;
999
+ env=EnvGen.kr(Env.adsr(att,decay,sus,rel),gate,levelScale:1,doneAction:2);
1000
+ fenv=EnvGen.kr(Env.adsr(fatt,fdecay,fsus,frel,curve:2),gate,levelScale:1,doneAction:2);
1001
+ vib=SinOsc.kr(vibrate).range(-1*vibdepth,vibdepth)+1;
1002
+ freq=Line.kr(freq,freq*ratio,5);
1003
+ freq=freq*vib;
1004
+ sig=Mix.ar(Saw.ar([freq,freq*(1+dtune)],mul:env*amp));
1005
+ // keep this below nyquist!!
1006
+ ffreq=max(fenv*freq*12,cutoff)+100;
1007
+ sig=LPF.ar(sig,ffreq);
1008
+ Out.ar(out, Pan2.ar(sig,pan) );
1009
+ SCLANG
1010
+ credit: "Vangelis/Blade Runner lead sound, based on tutorial by meastempo @ http://www.youtube.com/watch?v=Fne0oIEv-WI",
1011
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
1012
+ )
1013
+
1014
+ CYMBAL_808 = SynthDef.new(name: "cymbal808", params: { :out => 0, :baseFreq => 300, :time => 250, :amp => 0.1 },
1015
+ body: <<-SCLANG,
1016
+ //var freqs = [baseFreq, baseFreq*1.3420, baseFreq*1.2312, baseFreq*1.6532, baseFreq*1.9523, baseFreq*2.1523];
1017
+ //var freqs = [78.6, 140.44, 123.87, 219.4, 787.5, 531.3];
1018
+ //var freqs = [205.35, 254.29, 294.03, 304.41, 369.64, 522.71];
1019
+ var freqs = [205.35, 304.41, 369.64, 522.71, 540.54, 812.21];
1020
+ var signal, pulseEnv;
1021
+
1022
+ pulseEnv = EnvGen.ar(Env.new([1.0, 0.6], [time], [-0.5]), timeScale:(1/1000));
1023
+ signal = Mix.new(LFPulse.ar(freqs * 4.09));
1024
+ signal = (BinaryOpUGen('==', signal, 6.0) * 0.6) + (BinaryOpUGen('==', signal, 2.0) * 0.2) + (BinaryOpUGen('==', signal, 1.0) * 0.9); // XOR
1025
+ signal = (signal * pulseEnv) + (Mix.new(LFPulse.ar(freqs, width:0.55)) * 0.9);
1026
+ signal = RLPF.ar(signal, 7000, 0.6);
1027
+ signal = RHPF.ar(signal, 6800, 1.5);
1028
+ signal = RHPF.ar(signal, 6800, 1.5);
1029
+ signal = RHPF.ar(signal, 1200, 1.5);
1030
+ signal = signal + FreeVerb.ar(signal);
1031
+ signal = signal * EnvGen.ar(Env.new([0, 1, 0.4, 0, 0], [2, time, 50, 500], [0, -0.5, 0, -50]), timeScale:(1/1000), doneAction:2);
1032
+ signal = [signal, DelayN.ar(signal, 0.005, 0.005)];
1033
+ OffsetOut.ar(out, signal*4*amp);
1034
+ SCLANG
1035
+ credit: "Published on sc-users 2007-08-25 by Ryan Brown",
1036
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
1037
+ )
1038
+
1039
+ CYMBALIC_MCLD = SynthDef.new(name: "cymbalic_mcld", params: { :out => 0, :pan => 0, :amp => 0.1 },
1040
+ body: <<-SCLANG,
1041
+ var lodriver, locutoffenv, hidriver, hicutoffenv, freqs, res, thwack;
1042
+
1043
+ locutoffenv = EnvGen.ar(Env.perc(0.5, 5)) * 20000 + 10;
1044
+ lodriver = LPF.ar(WhiteNoise.ar(0.1), locutoffenv);
1045
+
1046
+ hicutoffenv = 10001 - (EnvGen.ar(Env.perc(1, 3)) * 10000);
1047
+ hidriver = HPF.ar(WhiteNoise.ar(0.1), hicutoffenv);
1048
+ hidriver = hidriver * EnvGen.ar(Env.perc(1, 2, 0.25));
1049
+
1050
+ thwack = EnvGen.ar(Env.perc(0.001,0.001,1));
1051
+
1052
+ // This bit will regenerate new freqs every time you evaluate the SynthDef!
1053
+ freqs = {exprand(300, 20000)}.dup(100);
1054
+
1055
+ res = Ringz.ar(lodriver + hidriver + thwack, freqs).mean;
1056
+
1057
+ Out.ar(out, Pan2.ar(((res * 1) + (lodriver * 2) + thwack) * amp, pan));
1058
+ SCLANG
1059
+ credit: "Based on the example at http://www.mcld.co.uk/cymbalsynthesis/ published 2008 by Dan Stowell",
1060
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
1061
+ )
1062
+
1063
+ KICK_CHIRP = SynthDef.new(name: "kick_chrp", params: { :out => 0, :amp => 1, :pan => 0 },
1064
+ body: <<-SCLANG,
1065
+ // a kick made using what radio folks would call a "chirp"
1066
+ var ampenv, pitchenv;
1067
+
1068
+ ampenv = EnvGen.ar(Env.perc(0, 0.2, curve: 0), doneAction: 2);
1069
+ pitchenv = EnvGen.ar(Env.perc(0, 0.1, curve: -20).exprange(0, 1000), doneAction: 0);
1070
+
1071
+ Out.ar(out, Pan2.ar(SinOsc.ar(pitchenv) * amp, pan));
1072
+ SCLANG
1073
+ credit: "by dan stowell. public domain",
1074
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
1075
+ )
1076
+
1077
+ KICK_OTO_309 = SynthDef.new(name: "kick_oto309", params: { :out => 0, :amp => 0.1, :pan => 0 },
1078
+ body: <<-SCLANG,
1079
+ var env0, env1, env1m, son;
1080
+
1081
+ env0 = EnvGen.ar(Env.new([0.5, 1, 0.5, 0], [0.005, 0.06, 0.26], [-4, -2, -4]), doneAction:2);
1082
+ env1 = EnvGen.ar(Env.new([110, 59, 29], [0.005, 0.29], [-4, -5]));
1083
+ env1m = env1.midicps;
1084
+
1085
+ son = LFPulse.ar(env1m, 0, 0.5, 1, -0.5);
1086
+ son = son + WhiteNoise.ar(1);
1087
+ son = LPF.ar(son, env1m*1.5, env0);
1088
+ son = son + SinOsc.ar(env1m, 0.5, env0);
1089
+
1090
+ son = son * 1.2;
1091
+ son = son.clip2(1);
1092
+
1093
+ Out.ar(out, Pan2.ar(son * amp));
1094
+ SCLANG
1095
+ credit: "from 08091500Acid309 by_otophilia",
1096
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
1097
+ )
1098
+
1099
+ ONECLAP = SynthDef.new(name: "oneclap", params: { :out => 0, :amp => 0.1, :filterfreq => 100, :rq => 0.1, :pan => 0 },
1100
+ body: <<-SCLANG,
1101
+ var env, signal, attack, noise, hpf1, hpf2;
1102
+ noise = WhiteNoise.ar(1)+SinOsc.ar([filterfreq/2,filterfreq/2+4 ], pi*0.5, XLine.kr(1,0.01,4));
1103
+ //noise = PinkNoise.ar(1)+SinOsc.ar([(filterfreq)*XLine.kr(1,0.01,3), (filterfreq+4)*XLine.kr(1,0.01,3) ], pi*0.5, XLine.kr(1,0.01,4));
1104
+ //signal = signal * SinOsc.ar(1,0.75);
1105
+ hpf1 = RLPF.ar(noise, filterfreq, rq);
1106
+ hpf2 = RHPF.ar(noise, filterfreq/2, rq/4);
1107
+ env = EnvGen.kr(Env.perc(0.003, 0.00035));
1108
+ signal = (hpf1+hpf2) * env;
1109
+ signal = CombC.ar(signal, 0.5, 0.03, 0.031)+CombC.ar(signal, 0.5, 0.03016, 0.06);
1110
+ //signal = Decay2.ar(signal, 0.5);
1111
+ signal = FreeVerb.ar(signal, 0.23, 0.15, 0.2);
1112
+ Out.ar(out, Pan2.ar(signal * amp, pan));
1113
+ DetectSilence.ar(signal, doneAction:2);
1114
+ SCLANG
1115
+ credit: "published on the sc-users list 2009-01-08 by thor",
1116
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
1117
+ )
1118
+
1119
+ PING_MH = SynthDef.new(name: "ping_mh", params: { :freq => 440,:amp => 0.2,:dur => 1,:attack => 0.001,:pan => 0,:out => 0 },
1120
+ body: <<-SCLANG,
1121
+ var sig,freq2;
1122
+ freq=freq*rrand(1,1.01);
1123
+ freq2=freq*rrand(1,1.01);
1124
+ e=EnvGen.ar(Env.perc(attack,dur,curve:-4),doneAction:2);
1125
+ sig=SinOsc.ar([freq,freq2],0,amp*e);
1126
+ sig=Pan2.ar(sig,pan);
1127
+ Out.ar(out,sig)
1128
+ SCLANG
1129
+ credit: "Your basic percussive synth instrument, a good default sound for testing patterns, etc.",
1130
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
1131
+ )
1132
+
1133
+ SNARE_OTO_309 = SynthDef.new(name: "snare_oto309", params: { :out => 0, :amp => 0.1, :pan => 0 },
1134
+ body: <<-SCLANG,
1135
+ var env0, env1, env2, env1m, oscs, noise, son;
1136
+
1137
+ env0 = EnvGen.ar(Env.new([0.5, 1, 0.5, 0], [0.005, 0.03, 0.10], [-4, -2, -4]));
1138
+ env1 = EnvGen.ar(Env.new([110, 60, 49], [0.005, 0.1], [-4, -5]));
1139
+ env1m = env1.midicps;
1140
+ env2 = EnvGen.ar(Env.new([1, 0.4, 0], [0.05, 0.13], [-2, -2]), doneAction:2);
1141
+
1142
+ oscs = LFPulse.ar(env1m, 0, 0.5, 1, -0.5) + LFPulse.ar(env1m * 1.6, 0, 0.5, 0.5, -0.25);
1143
+ oscs = LPF.ar(oscs, env1m*1.2, env0);
1144
+ oscs = oscs + SinOsc.ar(env1m, 0.8, env0);
1145
+
1146
+ noise = WhiteNoise.ar(0.2);
1147
+ noise = HPF.ar(noise, 200, 2);
1148
+ noise = BPF.ar(noise, 6900, 0.6, 3) + noise;
1149
+ noise = noise * env2;
1150
+
1151
+ son = oscs + noise;
1152
+ son = son.clip2(1) * amp;
1153
+
1154
+ Out.ar(out, Pan2.ar(son, pan));
1155
+ SCLANG
1156
+ credit: "from 08091500Acid309 by_otophilia",
1157
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
1158
+ )
1159
+
1160
+ SNARE_STEIN = SynthDef.new(name: "snare_stein", params: { :out => 0, :amp => 0.1, :pan => 0 },
1161
+ body: <<-SCLANG,
1162
+ var snare, filtWhite;
1163
+
1164
+ filtWhite = LPF.ar(WhiteNoise.ar(1), 7040, 1);
1165
+
1166
+ snare = (SinOsc.ar(330,0,0.25) * EnvGen.ar(Env.perc(0.0005,0.055))) + (SinOsc.ar(185,0,0.25) * EnvGen.ar(Env.perc(0.0005,0.075))) + (filtWhite * EnvGen.ar(Env.perc(0.0005,0.2), doneAction: 2) * 0.2) + (HPF.ar(filtWhite, 523, 1) * EnvGen.ar(Env.perc(0.0005,0.183)) * 0.2);
1167
+ Out.ar(out, Pan2.ar(snare * amp * 10, pan));
1168
+ SCLANG
1169
+ credit: "Snare written by Esben Stein, I believe",
1170
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
1171
+ )
1172
+
1173
+ SOS_BELL = SynthDef.new(name: "sos_bell", params: { :freq => 440, :out => 0, :amp => 0.1, :pan => 0 },
1174
+ body: <<-SCLANG,
1175
+ var son, strike, hum;
1176
+
1177
+ // Stretched harmonic series
1178
+ son = SinOsc.ar(#[2, 3, 4.1, 5.43, 6.8, 8.21] * freq, 0,
1179
+ #[1, 0.9, 0.8, 0.7, 0.6, 0.5] * 0.1);
1180
+
1181
+ son = son * EnvGen.ar(Env.new([0,1,0.3, 0.2, 0], [0, 0.3, 0.3, 0.3]));
1182
+
1183
+ // A bit of FM adds 'warble'
1184
+ son = son * LFTri.ar({Rand(1.0, 1.8)}.dup(6), 1, 0.3, 0.7);
1185
+
1186
+ // Mix down the partials in the main sound
1187
+ son = son.mean;
1188
+
1189
+ strike = SinOsc.ar(LFNoise1.ar(freq * 36, 100, freq*8), 1, 0.1) *
1190
+ EnvGen.ar(Env.new([0,1,0.2, 0.1, 0], [0, 0.01, 0, 0.04]));
1191
+
1192
+ hum = SinOsc.ar([freq*1.01, freq*0.47], 0, EnvGen.ar(Env.new([0,0.05,0.05,0], [0.5,0.5,1]), doneAction:2)).mean;
1193
+
1194
+ Out.ar(out, Pan2.ar((son + strike + hum) * 4 * amp, pan));
1195
+ SCLANG
1196
+ credit: "by dan stowell. based on a sound-on-sound 'synth secrets' tutorial",
1197
+ source: "https://github.com/supercollider-quarks/SynthDefPool",
1198
+ )
1199
+
1200
+
1201
+ KRGN_GEN_FMDEVIL = SynthDef.new(name: "krgn_gen_fmdevil", params: { :out => 0, :freq => 440, :amp => 1.0, :index => 3, :detune => 1.02, :gate => 1 },
1202
+ body: <<-SCLANG,
1203
+ var mod1, mod2, mod3, car, idx, env;
1204
+ env = EnvGen.ar(Env.adsr(0,0.4,0.3,0.2),gate: gate, levelScale: amp, doneAction: 2);
1205
+ idx = EnvGen.ar(Env.adsr(0,0.8,0.0,0.8),gate: gate, levelScale: index);
1206
+ mod1 = SinOsc.ar((freq / 12) * 2, LocalIn.ar(2), idx);
1207
+ mod2 = SinOsc.ar((freq / 12) * 6, mod1, idx);
1208
+ mod3 = SinOsc.ar([(freq / 12) * (9 * detune.neg), (freq / 12) * (9*detune)], mod2, idx);
1209
+ LocalOut.ar( mod3 * 0.25);
1210
+ car = SinOsc.ar(freq, mod3, env);
1211
+ Out.ar(out!2,car)
1212
+ SCLANG
1213
+ source: "https://github.com/mtytel/supersongs/",
1214
+ )
1215
+
1216
+ BOOP = SynthDef.new(name: "boop", params: { :out => 0, :dur => 1.0, :amp => 1.0, :freq => 440 },
1217
+ body: <<-SCLANG,
1218
+ var env, sig;
1219
+ env = EnvGen.ar(Env.new([1, 0.1, 0], [0.06, dur - 0.06]), doneAction: 2);
1220
+ sig = LFTri.ar([freq * 0.995, freq * 1.005], 0, env * amp);
1221
+ Out.ar(out, sig ! 2);
1222
+ SCLANG
1223
+ source: "https://github.com/mtytel/supersongs/",
1224
+ )
1225
+
1226
+ MARIO = SynthDef.new(name: "mario", params: { :out => 0, :freq => 440, :length => 0.1, :dur => 0.2 },
1227
+ body: <<-SCLANG,
1228
+ var snd, amp;
1229
+ snd = LFPulse.ar(freq)!2;
1230
+ amp = LFTri.ar(freq/50)!2;
1231
+ snd = snd * EnvGen.ar(Env.linen(0.001, length * dur, 0.03), doneAction:2);
1232
+ OffsetOut.ar(out, snd*amp);
1233
+ SCLANG
1234
+ source: "https://github.com/mtytel/supersongs/",
1235
+ )
1236
+
1237
+ MARIO_BASS = SynthDef.new(name: "mariobass", params: { :out => 0, :amp => 1.0, :freq => 440, :length => 0.1, :dur => 0.2 },
1238
+ body: <<-SCLANG,
1239
+ var snd;
1240
+ snd = LFTri.ar(freq)!2;
1241
+ snd = snd * EnvGen.ar(Env.linen(0.001, length * dur, 0.03), doneAction:2);
1242
+ OffsetOut.ar(out, snd*amp);
1243
+ SCLANG
1244
+ source: "https://github.com/mtytel/supersongs/",
1245
+ )
1246
+
1247
+ BEAT = SynthDef.new(name: "beat", params: { :out => 0, :amp => 1.0, :sustain => 0.1, :dur => 0.1 },
1248
+ body: <<-SCLANG,
1249
+ var snd;
1250
+ snd = BrownNoise.ar()!2;
1251
+ snd = HPF.ar(snd, 2000);
1252
+ snd = snd * EnvGen.ar(Env.linen(0.005, dur * sustain, 0.01), doneAction:2);
1253
+ OffsetOut.ar(out, snd*amp);
1254
+ SCLANG
1255
+ source: "https://github.com/mtytel/supersongs/",
1256
+ )
1257
+
1258
+ BASS2 = SynthDef.new(name: "bass2", params: { :out => 0, :freq => 440, :gate => 1, :amp => 1.0, :slideTime => 0.17, :ffreq => 1100, :width => 0.15, :detune => 1.005, :preamp => 4, :dur => 0.2, :length => 0.2 },
1259
+ body: <<-SCLANG,
1260
+ var sig,
1261
+ env = Env.adsr(0.01, 0.3, 0.4, 0.1);
1262
+ freq = Lag.kr(freq, slideTime);
1263
+ sig = Mix(VarSaw.ar([freq, freq * detune], 0, width, preamp)).distort * amp
1264
+ * EnvGen.kr(env, gate * dur * length , doneAction: 2);
1265
+ sig = LPF.ar(sig, ffreq);
1266
+ Out.ar(out, sig ! 2)
1267
+ SCLANG
1268
+ source: "https://github.com/mtytel/supersongs/",
1269
+ )
1270
+
1271
+
1272
+ DROPLET = SynthDef.new(name: "droplet", params: { :amp => 0.2, :out => 0, :freq => 3000, :dur => 1, :rate => 1 },
1273
+ body: <<-SCLANG,
1274
+ /**
1275
+ * No.2 - Droplet
1276
+ *
1277
+ * pitch envelope-based synth
1278
+ */
1279
+
1280
+ var sound,volEnv,pitchEnv, gate;
1281
+ gate = Pulse.kr(rate);
1282
+ pitchEnv=EnvGen.ar(Env.new([0.9,0.7,1,1],[0.06,0.05,0.89]*dur,\exponential), gate);
1283
+ volEnv=EnvGen.ar(Env.new([0,1,0.8,0.0],[0.2,0.05,0.75]*dur),gate);
1284
+ sound=SinOsc.ar(freq*pitchEnv,mul:volEnv);
1285
+ Out.ar(out, Pan2.ar(sound) * amp);
1286
+ SCLANG
1287
+ source: "https://github.com/johncburnett/Matrix",
1288
+ )
1289
+
1290
+ PHASE_MOD = SynthDef.new(name: "phaseMod", params: { :amp => 0.2, :out => 0, :freq => 30, :gate => 1 },
1291
+ body: <<-SCLANG,
1292
+ /**
1293
+ * No.4 - phaseMod
1294
+ *
1295
+ * Phase modulation
1296
+ */
1297
+
1298
+ var fund, oscA, oscB, pm, env, sig;
1299
+ fund = freq;
1300
+ oscA = PMOsc.ar(fund, fund / 2.05, 2pi * 0.1);
1301
+ oscB = SinOsc.ar(fund / 2.01, oscA * 2pi * 0.5);
1302
+ pm = SinOsc.ar(fund / 2.02, oscB * 2pi * 0.8);
1303
+ env = EnvGen.ar(Env.adsr, gate: gate);
1304
+ sig = env * pm;
1305
+ Out.ar(out, (amp*sig)!2);
1306
+ SCLANG
1307
+ source: "https://github.com/johncburnett/Matrix",
1308
+ )
1309
+
1310
+ NOISE = SynthDef.new(name: "noise", params: { :amp => 0.2, :out => 0 },
1311
+ body: <<-SCLANG,
1312
+ /**
1313
+ * No.5 - noise
1314
+ *
1315
+ */
1316
+
1317
+ var noise = HenonN.ar(SampleRate.ir/4, Rand(1,1.4), Rand(0,0.3)) * 0.2;
1318
+ Out.ar(out, noise!2 * amp);
1319
+ SCLANG
1320
+ source: "https://github.com/johncburnett/Matrix",
1321
+ )
1322
+
1323
+ NS_STATIC = SynthDef.new(name: "nsStatic", params: { :amp => 0.2, :out => 0,:mix => 0.9 },
1324
+ body: <<-SCLANG,
1325
+ /**
1326
+ * No.6 - nsSTatic
1327
+ *
1328
+ */
1329
+
1330
+ var sound, sound2, stereo, dummy, dummy2;
1331
+ dummy = Rand(0.2, 2.01);
1332
+ //dummy2 = 0.01*Rand(0, 100);
1333
+ dummy2 = mix;
1334
+ sound = Crackle.ar(dummy, 0.5, 0.5);//chaosParam val ~0.95 -> ~2.05
1335
+ sound2 = PitchShift.ar(sound, 0.2, 0.249, 0.02,2);
1336
+ mix = sound*dummy2 + (sound2*(1.0+(-1*dummy2)));
1337
+ stereo = Limiter.ar(Pan2.ar(mix), 0.5);
1338
+ Out.ar(out,stereo*amp);
1339
+ SCLANG
1340
+ source: "https://github.com/johncburnett/Matrix",
1341
+ )
1342
+
1343
+
1344
+
1345
+ POOM = SynthDef.new(name: "poom", params: { :out => 0, :freq => 400, :level => 0.1 },
1346
+ body: <<-SCLANG,
1347
+ var env = Env.perc(level: level);
1348
+ var envgen = EnvGen.kr(env, doneAction: 2);
1349
+ var sin = SinOsc.ar([freq, freq + 0.1], mul: envgen);
1350
+ var sin2 = SinOsc.ar([freq, freq + 0.1] * 17, mul: envgen / 17);
1351
+ Out.ar(out, sin + sin2);
1352
+ SCLANG
1353
+ source: "https://github.com/philthomson/imp",
1354
+ )
1355
+
1356
+ SINTH = SynthDef.new(name: "sinth", params: { :out => 0, :curve => 0, :dur => 1, :freq => 400, :level => 0.1 },
1357
+ body: <<-SCLANG,
1358
+ var env = Env.perc(releaseTime: dur, level: level, curve: curve);
1359
+ var envgen = EnvGen.kr(env, doneAction: 2);
1360
+ var sin = SinOsc.ar([freq, freq + 0.1], mul: envgen);
1361
+ var sin2 = SinOsc.ar([freq, freq + 0.1] * 2.01, mul: envgen / 8);
1362
+ var sin3 = SinOsc.ar([freq, freq * 0.1] * 20.1, mul: envgen / 32);
1363
+ Out.ar(out, sin + sin2 + sin3);
1364
+ SCLANG
1365
+ source: "https://github.com/philthomson/imp",
1366
+ )
1367
+
1368
+
1369
+ AEOLIAN_STRINGS = SynthDef.new(name: "aeolian_strings", params: { :out => 0 },
1370
+ body: <<-SCLANG,
1371
+ // aeolian strings
1372
+ var sig = Mix.fill(9,{i=Dust.ar(0.4)!2;CombC.ar(i,1,Select.ar(TIRand.kr(0,7,i),(55+Scale.aeolian.degrees).collect{|x|DC.ar(1/x.midicps)}),3)});
1373
+ Out.ar(out,sig);
1374
+ SCLANG
1375
+ source: "https://github.com/thormagnusson/sctweets",
1376
+ )
1377
+
1378
+ BONFIRE_NIGHT = SynthDef.new(name: "bonfire_night", params: { :out => 0 },
1379
+ body: <<-SCLANG,
1380
+ // the sound of new years eve in frosty Reykjavik
1381
+ var x=Decay;
1382
+ var d=Dust.ar(4);
1383
+ var sig = FreeVerb.ar(LPF.ar(x.ar(d,0.5,WhiteNoise.ar),2000)+x.ar(d,0.15,SinOsc.ar([40,47],pi,5)), 0.4,0.6,TRand.ar(0,1,d));
1384
+ Out.ar(out, sig);
1385
+ SCLANG
1386
+ source: "https://github.com/thormagnusson/sctweets",
1387
+ )
1388
+
1389
+ THAT_CLUB = SynthDef.new(name: "thatclub", params: { :out => 0 },
1390
+ body: <<-SCLANG,
1391
+ // the nightclub downstairs
1392
+ var x =SinOsc;
1393
+ var y =LFNoise0;
1394
+ var a = y.ar(8);
1395
+ var sig = x.ar(Pulse.ar(1)*24)+x.ar(90+(a*90))+MoogFF.ar(Saw.ar(y.ar(4,333,666)),a*XLine.ar(1,39,99,99,0,2));
1396
+ Out.ar(out, sig!2/3);
1397
+ SCLANG
1398
+ source: "https://github.com/thormagnusson/sctweets",
1399
+ )
1400
+
1401
+ DRUNK_DRUMMER = SynthDef.new(name: "drunk_drummer", params: { :out => 0 },
1402
+ body: <<-SCLANG,
1403
+ var i=Dust.ar(4), a=0.5, b=5e-3, q=Decay2, p=PulseDivider, n=WhiteNoise.ar;
1404
+ var sig = (SinOsc.ar(80)*q.ar(p.ar(i,2),a,b)+(n*q.ar(p.ar(i,4),b,a)));
1405
+ Out.ar(out,sig!2);
1406
+ SCLANG
1407
+ source: "https://github.com/thormagnusson/sctweets",
1408
+ )
1409
+
1410
+ EIGHTBIT_FUNK = SynthDef.new(name: "eightbit_funk", params: { :out => 0 },
1411
+ body: <<-SCLANG,
1412
+ // 8-bit funk
1413
+ var o=LFSaw.ar(LFSaw.kr(0.0005,-1).range(0.5,1)).abs*40;
1414
+ var sig = (o*15&(o>>5))|(o*100&(o>>1)&(o<<2))|(o*1e3&(o>>[1,2])&(LFSaw.kr(0.01).abs*5).ceil);
1415
+ Out.ar(out,sig!2);
1416
+ SCLANG
1417
+ source: "https://github.com/thormagnusson/sctweets",
1418
+ )
1419
+
1420
+ TWO_TIMPANIS = SynthDef.new(name: "two_timpanis", params: { :out => 0 },
1421
+ body: <<-SCLANG,
1422
+ var x=LFNoise0.ar(1)>0;
1423
+ var sig = SinOsc.ar(Spring.ar(x,4,3e-05)*(70.rand+190)+(30.rand+90))*EnvGen.kr(Env.perc(0.001,5),x);
1424
+ Out.ar(out, sig!2);
1425
+ SCLANG
1426
+ source: "https://github.com/thormagnusson/sctweets",
1427
+ )
1428
+
1429
+ TWO_TIMPANIS2 = SynthDef.new(name: "two_timpanis2", params: { :out => 0 },
1430
+ body: <<-SCLANG,
1431
+ var x=LFNoise0.ar(1)>0;
1432
+ var sig = SinOsc.ar(Spring.ar(x,4,3e-05)*(70.rand+190)+LFNoise2.ar(1).range(90,120))*EnvGen.kr(Env.perc(0.001,5),x);
1433
+ Out.ar(out, sig!2);
1434
+ SCLANG
1435
+ source: "https://github.com/thormagnusson/sctweets",
1436
+ )
1437
+
1438
+
1439
+ FM_TOM = SynthDef.new(name: "fmtom", params: { :out => 0, :freq => 200, :gate => 1, :vol => 0.5 },
1440
+ body: <<-SCLANG,
1441
+ var tom = PMOsc.ar(freq, 280, Line.kr(0.0, 12, 1), mul: EnvGen.ar(Env.adsr(0.003,0.2,0,0), gate, levelScale: 0.3, doneAction: 2));
1442
+ Out.ar(out, tom * vol ! 2);
1443
+ SCLANG
1444
+ source: "https://github.com/mattvears/supercollider-stuff",
1445
+ )
1446
+
1447
+ BASS_303 = SynthDef.new(name: "bass303", params: { :out => 0, :freq => 440, :gate => 1, :lpf => 1000, :res => 0.8, :width => 0.05, :amp => 1, :vol => 0.5 },
1448
+ body: <<-SCLANG,
1449
+ var sig, env;
1450
+ var sig2, env2;
1451
+
1452
+ // ghetto 303
1453
+ env = Env.adsr(0.05, 2, 0, 0.3, 0.8, -12);
1454
+ sig = LFPulse.ar(freq, width: width) + Pulse.ar(freq, width: 0.9);
1455
+ sig = sig * EnvGen.ar(env, gate, amp, doneAction: 2);
1456
+ sig = RLPF.ar(sig, lpf, res);
1457
+
1458
+ env2 = Env.adsr(0.03, 2, 0, 0.3, 0.8, -13);
1459
+ sig2 = LFPulse.ar(freq, width: width) + Pulse.ar(freq, width: 0.9);
1460
+ sig2 = FreqShift.ar(sig2, 3);
1461
+ sig2 = sig2 * EnvGen.ar(env2, gate, amp, doneAction: 2);
1462
+ sig2 = RLPF.ar(sig2, lpf, res);
1463
+
1464
+
1465
+ Out.ar(out, [sig * vol, sig2 * vol]);
1466
+
1467
+ SCLANG
1468
+ source: "https://github.com/mattvears/supercollider-stuff",
1469
+ )
1470
+
1471
+ # (
1472
+ # x = Signal.sineFill(513, [0.5, 0.2, 0.3, 0.0, 0.2]);
1473
+ # // x.plot;
1474
+ # b = Buffer.alloc(s, 1024, 1);
1475
+ # );
1476
+
1477
+ # b.sendCollection(x.asWavetableNoWrap);
1478
+
1479
+ # SynthDef.new(name: "kick909", params: { :out => 0, :startPitch => 100, :lpf1 => 100, :lpf2 => 200, :lpf3 => 200, :gate => 1 },
1480
+ # body: <<-SCLANG,
1481
+ # var sig1, adsr1;
1482
+ # var sig2, sig3, adsr2, adsr3, mixed;
1483
+
1484
+ # adsr1 = Env.adsr(0, 1, 0, 0.1, curve: -4);
1485
+ # adsr2 = Env.adsr(0, 0.1, 0, 0.1, curve: -8);
1486
+ # adsr3 = Env.adsr(0, 0.1, 0, 0.1);
1487
+
1488
+ # sig1 = Saw.ar(XLine.ar(startPitch, 1, 8, doneAction: 2));
1489
+ # sig1 = Shaper.ar(b.bufnum, sig1);
1490
+ # sig1 = sig1 * EnvGen.kr(adsr1, gate: gate, doneAction: 2);
1491
+ # sig1 = LPF.ar(sig1, lpf1);
1492
+
1493
+ # sig2 = LFPulse.ar(50, 0.1, 0.2) * EnvGen.kr(adsr2, gate: gate, doneAction: 2);
1494
+ # sig2 = LPF.ar(sig2, lpf2);
1495
+
1496
+ # sig3 = WhiteNoise.ar(0.5) * EnvGen.kr(adsr3, gate: gate, doneAction: 2);
1497
+ # sig3 = LPF.ar(sig3, lpf3);
1498
+
1499
+ # Out.ar(out, Mix.new([sig1, sig2, sig3]) ! 2);
1500
+ # SCLANG
1501
+ # source: "https://github.com/mattvears/supercollider-stuff",
1502
+ # )
1503
+
1504
+ SNARE_909 = SynthDef.new(name: "snare909", params: { :out => 0, :lpFreq => 1000, :vol => 1, :gate => 1 },
1505
+ body: <<-SCLANG,
1506
+ var sig1, sig2;
1507
+ var triEnv;
1508
+ var shifted1;
1509
+ var shifted2;
1510
+ var sinEnv;
1511
+ var sin1, sin2;
1512
+ var mixed;
1513
+ var sig3;
1514
+ var noiseEnv;
1515
+
1516
+ // tri -> final mixer
1517
+ triEnv = Env.adsr(0, 0.4, 0, 0, curve: -4, peakLevel: 0.5);
1518
+ sig1 = LFTri.ar(111, 0, 0.5) * EnvGen.kr(triEnv, gate: gate, doneAction: 2);
1519
+ shifted1 = FreqShift.ar(sig1, 175);
1520
+ shifted2 = FreqShift.ar(sig1, 224);
1521
+ sig1 = Mix.new([shifted1, shifted2]);
1522
+
1523
+ // sines -> final mixer
1524
+ sin1 = SinOsc.ar(330, mul: 0.2);
1525
+ sin2 = SinOsc.ar(180, mul: 0.2);
1526
+ sinEnv = Env.adsr(0, 0.2, 0, 0);
1527
+ sig2 = Mix.new([sin1, sin2]) * EnvGen.kr(sinEnv, gate: gate, doneAction: 2);
1528
+
1529
+ // noise -> final mixer
1530
+ noiseEnv = Env.adsr(0, 0.3, 0, 0);
1531
+ sig3 = LPF.ar(WhiteNoise.ar() * EnvGen.kr(noiseEnv, gate: gate, doneAction: 2), 1000);
1532
+ sig3 = HPF.ar(sig3, 600);
1533
+
1534
+ mixed = Mix.new([sig1, sig2, sig3]);
1535
+ mixed = LPF.ar(mixed, lpFreq) * vol;
1536
+ Out.ar(out, mixed ! 2);
1537
+ SCLANG
1538
+ source: "https://github.com/mattvears/supercollider-stuff",
1539
+ )
1540
+
1541
+
1542
+ HOOVER = SynthDef.new(name: "hoover", params: { :freq => 220, :amp => 0.1, :lgu => 0.1, :lgd => 1, :gate => 1 },
1543
+ body: <<-SCLANG,
1544
+ var pwm, mix, env;
1545
+
1546
+ freq = freq.cpsmidi.lag(lgu,lgd).midicps;
1547
+ freq = SinOsc.kr( { 2.9 rrand: 3.1 }!3, {2pi.rand}!3 ).exprange( 0.995, 1.005 ) * freq;
1548
+ pwm = SinOsc.kr( {2.0 rrand: 4.0}!3 ).range(0.125,0.875);
1549
+
1550
+ // the saw/pulses
1551
+ mix = (LFSaw.ar( freq * [0.25,0.5,1], 1 ).range(0,1)
1552
+ * (1 - LFPulse.ar(freq * [0.5,1,2], 0, pwm))).sum * 0.1;
1553
+
1554
+ // the bass
1555
+ mix = mix + LFPar.ar( freq * 0.25, 0, 0.1 );
1556
+
1557
+ // eq for extra sharpness
1558
+ mix = BPeakEQ.ar( mix, 6000, 1, 3 );
1559
+ mix = BPeakEQ.ar( mix, 3500, 1, 6 );
1560
+
1561
+ // kind of chorus
1562
+ mix = mix + CombC.ar( mix.dup, 1/200,
1563
+ SinOsc.kr( 3, [0.5pi, 1.5pi] ).range(1/300,1/200),
1564
+ 0.0 ) * 0.5;
1565
+
1566
+ env = EnvGen.kr( Env.asr, gate );
1567
+
1568
+ Out.ar( 0, mix * env * amp );
1569
+ SCLANG
1570
+ source: "https://github.com/rukano/scprivatepool",
1571
+ )
1572
+
1573
+
1574
+ SynthDef.new(name: "sawpulse", params: { :out => 0, :freq => 440, :gate => 0.5, :plfofreq => 6, :mw => 0, :ffreq => 2000, :rq => 0.3, :freqlag => 0.05, :amp => 1 },
1575
+ body: <<-SCLANG,
1576
+ var sig, plfo, fcurve;
1577
+ plfo = SinOsc.kr(plfofreq, mul:mw, add:1);
1578
+ freq = Lag.kr(freq, freqlag * 8) * plfo * 0.25;
1579
+ fcurve = EnvGen.kr(Env.adsr(0.1, 0.1, 0.4, 0.2), gate);
1580
+ fcurve = (fcurve - 1).madd(0.7, 1) * ffreq;
1581
+ sig = VarSaw.ar(freq*[1.001,3/2,1/2.001,1/4,1/2,3.001/2,1], width: LFNoise2.ar(0.3,0));
1582
+ //sig = BPF.ar(sig, fcurve, 0.2);
1583
+ // * EnvGen.kr(Env.adsr(0.01, 0.2, 0.8, 1), gate, doneAction:2)
1584
+ // * amp * 3;
1585
+ sig = sig * EnvGen.kr(Env.adsr(0.01, 0.2, 0.8, 1), gate, doneAction:2);
1586
+ Out.ar(out, Splay.ar(sig * 0.2, 1));
1587
+ SCLANG
1588
+ source: "https://github.com/bwestergard/supercollider-experiments",
1589
+ )
1590
+
1591
+ SynthDef.new(name: "sawpulse2", params: { :out => 0, :freq => 440, :gate => 0.5, :plfofreq => 6, :mw => 0, :ffreq => 2000, :rq => 0.3, :freqlag => 0.05, :amp => 1 },
1592
+ body: <<-SCLANG,
1593
+ var sig, plfo, fcurve;
1594
+ plfo = SinOsc.kr(plfofreq, mul:mw, add:1);
1595
+ freq = Lag.kr(freq, freqlag * 8) * plfo * 0.25;
1596
+ fcurve = EnvGen.kr(Env.adsr(0.1, 0.1, 0.4, 0.2), gate);
1597
+ fcurve = (fcurve - 1).madd(0.7, 1) * ffreq;
1598
+ sig = LFPulse.ar(freq*[1.001,3/2,1/2.001,1/4,1/2,3.001/2,1]*2, width: LFNoise2.ar(1/2).exprange(0.5,0.4));
1599
+ //sig = LPF.ar(sig, fcurve, 0.2) * 3;
1600
+ sig = sig * EnvGen.kr(Env.adsr(1, 0.2, 0.8, 0.3), gate, doneAction:2);
1601
+ Out.ar(out, Splay.ar(sig * 0.1, 1));
1602
+ SCLANG
1603
+ source: "https://github.com/bwestergard/supercollider-experiments",
1604
+ )
1605
+
1606
+ SynthDef.new(name: "sinepluck", params: { :out => 0, :freq => 440, :amp => 1, :dur => nil },
1607
+ body: <<-SCLANG,
1608
+ var mod,tone;
1609
+ amp = amp * 0.8;
1610
+ dur =1/6;
1611
+ mod = VarSaw.ar(freq*2, mul: XLine.ar(0.2,0.8,dur/2), width: XLine.ar(1,1/1000,dur*64));
1612
+ tone = SinOsc.ar(freq, mod).dup * 0.1 * XLine.ar(1,1/1000,dur*4, doneAction:2) * XLine.ar(1/1000,1,0.001) * amp;
1613
+ tone = [DelayC.ar(tone , 1, LFNoise2.ar(1/2).range(0,0.012)), DelayC.ar(tone , 1, LFNoise2.ar(1/2).range(0.012,0))];
1614
+ tone = tone * XLine.ar(1/10000,1,0.005);
1615
+ Out.ar(out,tone);
1616
+ SCLANG
1617
+ source: "https://github.com/bwestergard/supercollider-experiments",
1618
+ )
1619
+
1620
+ SynthDef.new(name: "snare", params: { :amp => 1, :dur => 0.05, :out => 0 },
1621
+ body: <<-SCLANG,
1622
+ dur = dur * 16;
1623
+ Out.ar(out, amp * XLine.ar(2,1/1000,dur) * BPF.ar(PinkNoise.ar(0.8), XLine.ar(20000,1000,dur, doneAction:2), 0.8).dup);
1624
+ SCLANG
1625
+ source: "https://github.com/bwestergard/supercollider-experiments",
1626
+ )
1627
+
1628
+ SynthDef.new(name: "kick", params: { :out => 0, :amp => 1, :dur => 0.05 },
1629
+ body: <<-SCLANG,
1630
+ var tone;
1631
+ tone = SinOsc.ar(XLine.ar(800,2,dur*4, mul: 0.2, doneAction:2));
1632
+ Out.ar(out, amp * tone.dup * XLine.ar(2,1/1000,dur*4));
1633
+ SCLANG
1634
+ source: "https://github.com/bwestergard/supercollider-experiments",
1635
+ )
1636
+
1637
+
1638
+ SynthDef.new(name: "poly1", params: { :out => 0, :gate => 1, :freq => 440 },
1639
+ body: <<-SCLANG,
1640
+ var aEnv,fEnv,osc1, osc2,flt;
1641
+ aEnv=EnvGen.kr(Env.asr(0.2,1,0.1), gate, doneAction:2);
1642
+ fEnv=EnvGen.kr(Env.asr(7,1,0.2), levelScale:12000);
1643
+ osc1=Pulse.ar(freq*[1,1007], LFCub.kr(2,0,0.3,0.5));
1644
+ osc2= Pulse.ar(freq/2,0.3);
1645
+ flt=RLPF.ar(osc1+osc2, fEnv,0.9, aEnv);
1646
+ Out.ar(out, flt);
1647
+ SCLANG
1648
+ source: "https://github.com/k-o-l-e-k-t-i-v/supercollider",
1649
+ )
1650
+
1651
+
1652
+ end
1653
+ end
1654
+ end