renoise 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a351542a433ad5f3c7b247afe1af47e9b6794f32
4
+ data.tar.gz: 56d4fb8df89f944164663f1097f02f1f694f208c
5
+ SHA512:
6
+ metadata.gz: c168ab5147ec92a1ced0664b954cb6e32a737a948375ab751debffd7b9dce062d866987a2ec753fb9143580f6372327b7c4439282aec4b9026ea01ce9371823d
7
+ data.tar.gz: 80822af9a49e0b2aae6f6b86bdc680ec8477783fff87bafc81fa08e5c44e71a1933e6e7c8c37960989a4bf5349985052b312eef0111398e902f49ee2bd11a69f
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.swp
16
+ *.swo
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in renoise.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Adrian Enns
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Renoise
2
+
3
+ Make Sound with programs you love. Renoise and Ruby.
4
+
5
+ This is not a final release.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'renoise'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install renoise
22
+
23
+ ## REPL
24
+
25
+ $ renoise-repl
26
+ host: localhost
27
+ port: 8000
28
+ >> help
29
+
30
+ ## Usage
31
+
32
+ require "renoise"
33
+
34
+ r = Renoise::Core.new('localhost', 8000)
35
+ r.stop
36
+ r.seq :drums, 36, 1, 1
37
+ r.config :drums, beats: 1
38
+ r.bpm = 120
39
+ r.notes :drums, 0, -1, 1, -1, 0, 1, -1, 1
40
+ r.play
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it ( https://github.com/addisaden/renoise-ruby/fork )
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/renoise-repl ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/env ruby
2
+
3
+ require "renoise"
4
+ require "renoise/repl"
5
+
6
+ Renoise::Repl.new
data/lib/renoise.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "renoise/version"
2
+ require "renoise/core"
3
+
4
+ module Renoise
5
+ end
@@ -0,0 +1,37 @@
1
+ require "osc-ruby"
2
+ require "renoise/sequencer"
3
+
4
+ module Renoise
5
+ class Core
6
+ include Renoise::Sequencer
7
+
8
+ def initialize(host, port)
9
+ @renoise = OSC::Client.new(host, port)
10
+ self.bpm = 120
11
+ seq_init
12
+ end
13
+
14
+ def bpm=(bpm)
15
+ send_msg "/renoise/song/bpm", bpm
16
+ @bpm = bpm
17
+ end
18
+
19
+ def panic
20
+ send_msg "/renoise/transport/panic"
21
+ end
22
+
23
+ def note_on(instr, track, note, val)
24
+ send_msg "/renoise/trigger/note_on", instr, track, note, val
25
+ end
26
+
27
+ def note_off(instr, track, note)
28
+ send_msg "/renoise/trigger/note_off", instr, track, note
29
+ end
30
+
31
+ private
32
+
33
+ def send_msg(*args)
34
+ @renoise.send(OSC::Message.new(*args))
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,204 @@
1
+ require "renoise/core"
2
+ require "readline"
3
+
4
+ # seq_play, seq_pause, seq_stop, panic
5
+ #
6
+ # seq_drop(name)
7
+ # seq_status
8
+ # seq(name, basenote, instr, track)
9
+ # config(name, **config)
10
+ # instrument: instr,
11
+ # track: track,
12
+ # value: 100,
13
+ # basenote: basenote,
14
+ # beat: 4,
15
+ # length: 1,
16
+ # notes: []
17
+ # notes(name, *notes)
18
+
19
+ module Renoise
20
+ class Repl
21
+ RESERVED = ["rm", "config", "notes", "ls", "play", "pause", "stop", "panic", "bpm", "help"]
22
+ LS = /^\s*ls/i
23
+ SEQUENCE = /^\s*([[:word:]]+)\s+(\d+)\s+(\d+)\s+(\d+)/i
24
+ CONFIGURATION = /^\s*config\s+([[:word:]]+)\s+((\s*(\w+)\s+(\d+)){1,})/i
25
+ NOTES = /^\s*notes\s+([[:word:]]+)((\s+-?\d+){1,})/i
26
+ BPM = /^\s*bpm\s+(\d+)/i
27
+ RM = /^\s*rm\s+([[:word:]]+)/i
28
+
29
+ def initialize
30
+ puts "Renoise Repl ... Bootup"
31
+ puts "Please be aware to Start Renoise-OSC Server in UDP-Mode"
32
+ @host = Readline.readline("Host: ", true)
33
+ @port = Readline.readline("Port: ", true).to_i
34
+
35
+ print "Setup connection ... "
36
+ @renoise = Renoise::Core.new(@host, @port)
37
+ puts "Done"
38
+ print "Setup BPM to 120 ... "
39
+ @renoise.bpm = 120
40
+ puts "Done"
41
+
42
+ repl
43
+
44
+ @renoise.seq_stop
45
+ @renoise.panic
46
+ puts "Good Bye :)"
47
+ end
48
+
49
+ def repl
50
+ loop do
51
+ begin
52
+ input = Readline.readline(">> ", true)
53
+
54
+ input = input.split(';').map { |s| s.strip }
55
+
56
+ input.each do |iii|
57
+ @input = iii
58
+
59
+ if @input =~ /exit/i then
60
+ return
61
+ elsif @input =~ /^play/i then
62
+ @renoise.seq_play
63
+ elsif @input =~ /^pause/i then
64
+ @renoise.seq_pause
65
+ elsif @input =~ /^stop/i then
66
+ @renoise.seq_stop
67
+ elsif @input =~ /^panic/i then
68
+ panic
69
+ elsif @input =~ /^help/i then
70
+ puts "- control -"
71
+ puts "play <- Play"
72
+ puts "pause <- Pause"
73
+ puts "stop <- Stop"
74
+ puts "panic <- Stops everything"
75
+ puts "bpm <number> <- Set Beats per Minute"
76
+ puts
77
+ puts "- sequencer -"
78
+ puts "<name> <basenote> <instrument> <track> <- create a sequence"
79
+ puts "ls <- Linst sequences"
80
+ puts "config <name> ...key val <- change configuration of sequence"
81
+ puts "notes <name> <midinotes...> <- set notes (negative for silence)"
82
+ puts "rm <seqname> <- Remove a sequence"
83
+ elsif @input =~ RM then
84
+ rm
85
+ elsif @input =~ BPM then
86
+ bpm
87
+ elsif @input =~ LS then
88
+ list
89
+ elsif @input =~ NOTES then
90
+ notes
91
+ elsif @input =~ CONFIGURATION then
92
+ configuration
93
+ elsif @input =~ SEQUENCE then
94
+ sequence
95
+ else
96
+ puts "no command."
97
+ end
98
+ end
99
+ rescue => e
100
+ puts "err"
101
+ end
102
+ end
103
+ end
104
+
105
+ def panic
106
+ @renoise.panic
107
+ end
108
+
109
+ def bpm
110
+ i = @input.match(BPM)
111
+ bpm = i[1].to_i
112
+ @renoise.bpm = bpm
113
+ end
114
+
115
+ def rm
116
+ i = @input.match(RM)
117
+ name = i[1]
118
+ unless @renoise.seq_status[:sequencers].include? name then
119
+ puts "Sorry, sequence doesn't exist."
120
+ return
121
+ end
122
+ @renoise.seq_drop name
123
+ list
124
+ end
125
+
126
+ def notes
127
+ # notes(name, *notes)
128
+ i = @input.match(NOTES)
129
+ name = i[1]
130
+ unless @renoise.seq_status[:sequencers].include? name then
131
+ puts "Sorry, sequence doesn't exist."
132
+ return
133
+ end
134
+ notes = (i[2]).strip.split(/\s+/).map { |i| i.to_i }
135
+ @renoise.notes name, *notes
136
+ list
137
+ end
138
+
139
+ def sequence
140
+ # seq(name, basenote, instr, track)
141
+ i = @input.match(SEQUENCE)
142
+ name = i[1]
143
+ if RESERVED.include? name then
144
+ puts "Sorry name is reserved."
145
+ return
146
+ end
147
+ basenote = i[2].to_i
148
+ instr = i[3].to_i
149
+ track = i[4].to_i
150
+ @renoise.seq name, basenote, instr, track
151
+ list
152
+ end
153
+
154
+ def configuration
155
+ i = @input.match(CONFIGURATION)
156
+ name = i[1]
157
+ unless @renoise.seq_status[:sequencers].include? name then
158
+ puts "Sorry, sequence doesn't exist."
159
+ return
160
+ end
161
+ config = i[2].split(/\s+/i).map { |c| c =~ /^\d+$/ ? c.to_i : c }
162
+ (config.length / 2).times do |i|
163
+ @renoise.config name, { config[i*2].to_sym => config[(i*2) + 1] }
164
+ end
165
+ list
166
+ end
167
+
168
+ def list
169
+ status = @renoise.seq_status
170
+ puts "\n#{ status[:play] ? 'PLAYING' : 'STOPPED' } Takt: #{ status[:position] / 4 + 1 } Note: #{ status[:position] % 4 + 1}"
171
+
172
+ temp_show_seq = Class.new do
173
+ def initialize(k, v)
174
+ @name = k
175
+ @instr = v[:instrument]
176
+ @track = v[:track]
177
+ @value = v[:value]
178
+ @basenote = v[:basenote]
179
+ @beat = v[:beat]
180
+ @length = v[:length]
181
+ @notes = v[:notes].map { |n| note_to_s(n) }
182
+ end
183
+
184
+ def note_to_s(note)
185
+ if note < 0 then
186
+ return "-"
187
+ end
188
+ b = %w{c c# d d# e f f# g g# a a# h}[note % 12]
189
+ b += note / 12 < 1 ? '' : (note / 12).to_s
190
+ return b
191
+ end
192
+
193
+ def to_s
194
+ "\n-- #{ @name } --\ninstrument=#{ @instr } track=#{ @track }\nbeat=#{ @beat } basenote=#{ @basenote } value=#{ @value} length=#{ @length }\n#{ @notes.join(' ') }"
195
+ end
196
+ end
197
+
198
+ status[:sequencers].each do |k, v|
199
+ puts temp_show_seq.new(k, v)
200
+ end
201
+ puts
202
+ end
203
+ end
204
+ end
@@ -0,0 +1,102 @@
1
+ module Renoise
2
+ module Sequencer
3
+ def seq_init
4
+ @sequencers = {}
5
+ @sequencer = {
6
+ position: 0,
7
+ played: [], # [stop_position, instr, track, note]
8
+ play: true
9
+ }
10
+
11
+ @sequencer_thread = Thread.new do
12
+ loop do
13
+ # stop notes
14
+ @sequencer[:played].each_index do |i|
15
+ n = @sequencer[:played][i]
16
+ if n[0] <= @sequencer[:position] then
17
+ note_off(n[1], n[2], n[3])
18
+ @sequencer[:played].delete_at(i)
19
+ end
20
+ end
21
+
22
+ # play notes
23
+ notes_to_play = []
24
+
25
+ if @sequencer[:play] then
26
+ @sequencers.each do |name, config|
27
+ if @sequencer[:position] % config[:beat] == 0 and config[:notes].length > 0 then
28
+ note = config[:notes][(@sequencer[:position] / config[:beat]) % config[:notes].length]
29
+ if note >= 0 then
30
+ note += config[:basenote]
31
+ notes_to_play << [config[:instrument], config[:track], note, config[:value], @sequencer[:position] + config[:length]]
32
+ end
33
+ end
34
+ end
35
+
36
+ notes_to_play.each do |n|
37
+ note_on(n[0], n[1], n[2], n[3])
38
+ @sequencer[:played] << [n[4], n[0], n[1], n[2]]
39
+ end
40
+
41
+ @sequencer[:position] += 1
42
+ end
43
+
44
+ # wait a tick
45
+ sleep (60.0 / (@bpm * 4))
46
+ end
47
+ end
48
+ end
49
+
50
+ def seq_pause
51
+ @sequencer[:play] = false
52
+ @sequencer[:played].each do |n|
53
+ note_off(n[1], n[2], n[3])
54
+ @sequencer[:played].delete(n)
55
+ end
56
+ end
57
+
58
+ def seq_stop
59
+ seq_pause
60
+ panic
61
+ @sequencer[:position] = 0
62
+ end
63
+
64
+ def seq_play
65
+ @sequencer[:play] = true
66
+ end
67
+
68
+ def seq_drop(name)
69
+ if @sequencers.keys.include? name then
70
+ @sequencers.delete[name]
71
+ end
72
+ end
73
+
74
+ def seq_status
75
+ { :sequencers => @sequencers, :play => @sequencer[:play], :position => @sequencer[:position] }
76
+ end
77
+
78
+ def seq(name, basenote, instr, track)
79
+ @sequencers[name] = {
80
+ instrument: instr,
81
+ track: track,
82
+ value: 100,
83
+ basenote: basenote,
84
+ beat: 4,
85
+ length: 1,
86
+ notes: []
87
+ }
88
+ end
89
+
90
+ def config(name, **config)
91
+ if @sequencers.keys.include? name then
92
+ @sequencers[name].merge!(config)
93
+ end
94
+ end
95
+
96
+ def notes(name, *notes)
97
+ if @sequencers.keys.include? name then
98
+ @sequencers[name][:notes] = notes
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,3 @@
1
+ module Renoise
2
+ VERSION = "0.0.1"
3
+ end
data/renoise.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'renoise/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "renoise"
8
+ spec.version = Renoise::VERSION
9
+ spec.authors = ["Adrian Enns"]
10
+ spec.email = ["addis.aden@gmail.com"]
11
+ spec.summary = %q{Renoise OSC Control for Ruby}
12
+ spec.description = %q{Play with your code to make music in Ruby}
13
+ spec.homepage = "https://github.com/addisaden/renoise-ruby/"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "pry"
24
+ spec.add_dependency "osc-ruby", "~> 1.1"
25
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: renoise
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Adrian Enns
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: osc-ruby
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
69
+ description: Play with your code to make music in Ruby
70
+ email:
71
+ - addis.aden@gmail.com
72
+ executables:
73
+ - renoise-repl
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/renoise-repl
83
+ - lib/renoise.rb
84
+ - lib/renoise/core.rb
85
+ - lib/renoise/repl.rb
86
+ - lib/renoise/sequencer.rb
87
+ - lib/renoise/version.rb
88
+ - renoise.gemspec
89
+ homepage: https://github.com/addisaden/renoise-ruby/
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.4.5
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Renoise OSC Control for Ruby
113
+ test_files: []