voicemeeter 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md ADDED
@@ -0,0 +1,775 @@
1
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)][license]
2
+ [![Ruby Code Style](https://img.shields.io/badge/code_style-standard-violet.svg)](https://github.com/standardrb/standard)
3
+
4
+ # Ruby Wrapper Around the Voicemeeter Remote API
5
+
6
+ This gem offers a Ruby interface for the Voicemeeter Remote API.
7
+
8
+ For an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)
9
+
10
+ ## Tested against
11
+
12
+ - Basic 1.0.8.8
13
+ - Banana 2.0.6.8
14
+ - Potato 3.0.2.8
15
+
16
+ ## Requirements
17
+
18
+ - [Voicemeeter](https://voicemeeter.com/)
19
+ - Ruby 3.2 or greater
20
+
21
+ ## Installation
22
+
23
+ ### Bundler
24
+
25
+ ```
26
+ bundle add voicemeeter
27
+ bundle install
28
+ ```
29
+
30
+ ## `Use`
31
+
32
+ Simplest use case, request a Remote class of a kind, then pass a block to run.
33
+
34
+ Login and logout are handled for you in this scenario.
35
+
36
+ #### `main.rb`
37
+
38
+ ```ruby
39
+ require "voicemeeter"
40
+
41
+ class Main
42
+ def run
43
+ Voicemeeter::Remote.new(:banana).run do |vm|
44
+ vm.strip[0].label = "podmic"
45
+ vm.strip[0].mute = true
46
+ puts "strip 0 #{vm.strip[0].label} mute was set to #{vm.strip[0].mute}"
47
+
48
+ vm.bus[3].gain = -6.3
49
+ vm.bus[4].eq.on = true
50
+ info = [
51
+ "bus 3 gain has been set to #{vm.bus[3].gain}",
52
+ "bus 4 eq has been set to #{vm.bus[4].eq.on}"
53
+ ]
54
+ puts info
55
+ end
56
+ end
57
+ end
58
+
59
+ Main.new.run if $PROGRAM_NAME == __FILE__
60
+ ```
61
+
62
+ Otherwise you must remember to call `vm.login` `vm.logout` at the start/end of your code.
63
+
64
+ ## `KIND_ID`
65
+
66
+ Pass the kind of Voicemeeter as an argument. KIND_ID may be:
67
+
68
+ - `:basic`
69
+ - `:banana`
70
+ - `:potato`
71
+
72
+ ## `Available commands`
73
+
74
+ ### Strip
75
+
76
+ The following attributes are available.
77
+
78
+ - `mono`: boolean
79
+ - `solo`: boolean
80
+ - `mute`: boolean
81
+ - `gain`: float, from -60.0 to 12.0
82
+ - `audibility`: float, from 0.0 to 10.0
83
+ - `limit`: int, from -40 to 12
84
+ - `A1 - A5`, `B1 - B3`: boolean
85
+ - `label`: string
86
+ - `mc`: boolean
87
+ - `karaoke`: int, from 0 to 4
88
+ - `bass`: float, from -12.0 to 12.0
89
+ - `mid`: float, from -12.0 to 12.0
90
+ - `treble`: float, from -12.0 to 12.0
91
+ - `reverb`: float, from 0.0 to 10.0
92
+ - `delay`: float, from 0.0 to 10.0
93
+ - `fx1`: float, from 0.0 to 10.0
94
+ - `fx2`: float, from 0.0 to 10.0
95
+ - `pan_x`: float, from -0.5 to 0.5
96
+ - `pan_y`: float, from 0.0 to 1.0
97
+ - `color_x`: float, from -0.5 to 0.5
98
+ - `color_y`: float, from 0.0 to 1.0
99
+ - `fx_x`: float, from -0.5 to 0.5
100
+ - `fx_y`: float, from 0.0 to 1.0
101
+ - `postreverb`: boolean
102
+ - `postdelay`: boolean
103
+ - `postfx1`: boolean
104
+ - `postfx2`: boolean
105
+
106
+ example:
107
+
108
+ ```ruby
109
+ vm.strip[3].gain = 3.7
110
+ puts vm.strip[0].label
111
+ ```
112
+
113
+ The following methods are available.
114
+
115
+ - `appgain(name, value)`: string, float, from 0.0 to 1.0
116
+
117
+ Set the gain in db by value for the app matching name.
118
+
119
+ - `appmute(name, value)`: string, bool
120
+
121
+ Set mute state as value for the app matching name.
122
+
123
+ example:
124
+
125
+ ```ruby
126
+ vm.strip[5].appgain("Spotify", 0.5)
127
+ vm.strip[5].appmute("Spotify", true)
128
+ ```
129
+
130
+ #### Comp
131
+
132
+ The following attributes are available.
133
+
134
+ - `knob`: float, from 0.0 to 10.0
135
+ - `gainin`: float, from -24.0 to 24.0
136
+ - `ratio`: float, from 1.0 to 8.0
137
+ - `threshold`: float, from -40.0 to -3.0
138
+ - `attack`: float, from 0.0 to 200.0
139
+ - `release`: float, from 0.0 to 5000.0
140
+ - `knee`: float, from 0.0 to 1.0
141
+ - `gainout`: float, from -24.0 to 24.0
142
+ - `makeup`: boolean
143
+
144
+ example:
145
+
146
+ ```ruby
147
+ puts vm.strip[4].comp.knob
148
+ ```
149
+
150
+ Strip Comp parameters are defined for PhysicalStrips.
151
+
152
+ `knob` defined for all versions, all other parameters potato only.
153
+
154
+ #### Gate
155
+
156
+ The following attributes are available.
157
+
158
+ - `knob`: float, from 0.0 to 10.0
159
+ - `threshold`: float, from -60.0 to -10.0
160
+ - `damping`: float, from -60.0 to -10.0
161
+ - `bpsidechain`: int, from 100 to 4000
162
+ - `attack`: float, from 0.0 to 1000.0
163
+ - `hold`: float, from 0.0 to 5000.0
164
+ - `release`: float, from 0.0 to 5000.0
165
+
166
+ example:
167
+
168
+ ```ruby
169
+ vm.strip[2].gate.attack = 300.8
170
+ ```
171
+
172
+ Strip Gate parameters are defined for PhysicalStrips.
173
+
174
+ `knob` defined for all versions, all other parameters potato only.
175
+
176
+ #### Denoiser
177
+
178
+ The following attributes are available.
179
+
180
+ - `knob`: float, from 0.0 to 10.0
181
+
182
+ example:
183
+
184
+ ```ruby
185
+ vm.strip[0].denoiser.knob = 0.5
186
+ ```
187
+
188
+ Strip Denoiser parameters are defined for PhysicalStrips, potato version only.
189
+
190
+ #### EQ
191
+
192
+ The following attributes are available.
193
+
194
+ - `on`: boolean
195
+ - `ab`: boolean
196
+
197
+ example:
198
+
199
+ ```ruby
200
+ vm.strip[0].eq.ab = True
201
+ ```
202
+
203
+ Strip EQ parameters are defined for PhysicalStrips, potato version only.
204
+
205
+ ##### Gainlayers
206
+
207
+ - `gain`: float, from -60.0 to 12.0
208
+
209
+ example:
210
+
211
+ ```ruby
212
+ vm.strip[3].gainlayer[3].gain = 3.7
213
+ ```
214
+
215
+ Gainlayers are defined for potato version only.
216
+
217
+ ##### Levels
218
+
219
+ The following attributes are available.
220
+
221
+ - `prefader`
222
+ - `postfader`
223
+ - `postmute`
224
+
225
+ example:
226
+
227
+ ```ruby
228
+ puts vm.strip[3].levels.prefader
229
+ ```
230
+
231
+ Level properties will return -200.0 if no audio detected.
232
+
233
+ ### Bus
234
+
235
+ The following attributes are available.
236
+
237
+ - `mono`: boolean
238
+ - `mute`: boolean
239
+ - `sel`: boolean
240
+ - `gain`: float, from -60.0 to 12.0
241
+ - `label`: string
242
+ - `returnreverb`: float, from 0.0 to 10.0
243
+ - `returndelay`: float, from 0.0 to 10.0
244
+ - `returnfx1`: float, from 0.0 to 10.0
245
+ - `returnfx2`: float, from 0.0 to 10.0
246
+ - `monitor`: boolean
247
+
248
+ example:
249
+
250
+ ```ruby
251
+ vm.bus[3].gain = 3.7
252
+ puts vm.bus[0].label
253
+
254
+ vm.bus[4].mono = true
255
+ ```
256
+
257
+ ##### EQ
258
+
259
+ The following attributes are available.
260
+
261
+ - `on`: boolean
262
+ - `ab`: boolean
263
+
264
+ example:
265
+
266
+ ```ruby
267
+ vm.bus[4].eq.on = true
268
+ ```
269
+
270
+ ##### Modes
271
+
272
+ The following attributes are available.
273
+
274
+ - `normal`: boolean
275
+ - `amix`: boolean
276
+ - `bmix`: boolean
277
+ - `composite`: boolean
278
+ - `tvmix`: boolean
279
+ - `upmix21`: boolean
280
+ - `upmix41`: boolean
281
+ - `upmix61`: boolean
282
+ - `centeronly`: boolean
283
+ - `lfeonly`: boolean
284
+ - `rearonly`: boolean
285
+
286
+ The following methods are available.
287
+
288
+ - `get`
289
+
290
+ example:
291
+
292
+ ```ruby
293
+ vm.bus[4].mode.amix = true
294
+ puts vm.bus[3].mode.get
295
+ ```
296
+
297
+ ##### Levels
298
+
299
+ The following attributes are available.
300
+
301
+ - `all`
302
+
303
+ example:
304
+
305
+ ```ruby
306
+ puts vm.bus[0].levels.all
307
+ ```
308
+
309
+ `levels.all` will return -200.0 if no audio detected.
310
+
311
+ ### Strip | Bus
312
+
313
+ The following methods are available
314
+
315
+ - `fadeto(amount, time)`: float, int
316
+ - `fadeby(amount, time)`: float, int
317
+
318
+ Modify gain to or by the selected amount in db over a time interval in ms.
319
+
320
+ example:
321
+
322
+ ```ruby
323
+ vm.strip[0].fadeto(-10.3, 1000)
324
+ vm.bus[3].fadeby(-5.6, 500)
325
+ ```
326
+
327
+ #### Strip.Device | Bus.Device
328
+
329
+ The following attributes are available
330
+
331
+ - `name`: str
332
+ - `sr`: int
333
+ - `wdm`: str
334
+ - `ks`: str
335
+ - `mme`: str
336
+ - `asio`: str
337
+
338
+ example:
339
+
340
+ ```ruby
341
+ puts vm.strip[0].device.name
342
+ vm.bus[0].device.asio = "Audient USB Audio ASIO Driver"
343
+ ```
344
+
345
+ strip|bus device parameters are defined for physical channels only.
346
+
347
+ name, sr are read only. wdm, ks, mme, asio are write only.
348
+
349
+ ### Macrobuttons
350
+
351
+ Three modes defined: state, stateonly and trigger.
352
+
353
+ - `state`: boolean
354
+ - `stateonly`: boolean
355
+ - `trigger`: boolean
356
+
357
+ example:
358
+
359
+ ```ruby
360
+ vm.button[37].state = true
361
+ vm.button[55].trigger = false
362
+ ```
363
+
364
+ ### Recorder
365
+
366
+ The following attributes accept boolean values.
367
+
368
+ - `loop`: boolean
369
+ - `A1 - A5`: boolean
370
+ - `B1 - A3`: boolean
371
+
372
+ The following methods are available
373
+
374
+ - `play`
375
+ - `stop`
376
+ - `pause`
377
+ - `record`
378
+ - `ff`
379
+ - `rew`
380
+ - `load(filepath)`: string
381
+
382
+ example:
383
+
384
+ ```ruby
385
+ vm.recorder.play
386
+ vm.recorder.stop
387
+
388
+ # Enable loop play
389
+ vm.recorder.loop = true
390
+
391
+ # Disable recorder out channel B2
392
+ vm.recorder.B2 = false
393
+
394
+ # filepath as string
395
+ vm.recorder.load('C:\music\mytune.mp3')
396
+ ```
397
+
398
+ ### VBAN
399
+
400
+ - `vm.vban.enable` | `vm.vban.disable` Turn VBAN on or off
401
+
402
+ ##### Instream | Outstream
403
+
404
+ The following attributes are available.
405
+
406
+ - `on`: boolean
407
+ - `name`: string
408
+ - `ip`: string
409
+ - `port`: int, range from 1024 to 65535
410
+ - `sr`: int, (11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000)
411
+ - `channel`: int, from 1 to 8
412
+ - `bit`: int, 16 or 24
413
+ - `quality`: int, from 0 to 4
414
+ - `route`: int, from 0 to 8
415
+
416
+ SR, channel and bit are defined as readonly for instreams. Attempting to write to those parameters will throw an error. They are read and write for outstreams.
417
+
418
+ example:
419
+
420
+ ```ruby
421
+ # turn VBAN on
422
+ vm.vban.enable
423
+
424
+ # turn on vban instream 0
425
+ vm.vban.instream[0].on = true
426
+
427
+ # set bit property for outstream 3 to 24
428
+ vm.vban.outstream[3].bit = 24
429
+ ```
430
+
431
+ ### Command
432
+
433
+ Certain 'special' commands are defined by the API as performing actions rather than setting values. The following methods are available:
434
+
435
+ - `show` : Bring Voiceemeter GUI to the front
436
+ - `hide` : Hide Voicemeeter GUI
437
+ - `shutdown` : Shuts down the GUI
438
+ - `restart` : Restart the audio engine
439
+
440
+ The following attributes are write only and accept boolean values.
441
+
442
+ - `showvbanchat`: boolean
443
+ - `lock`: boolean
444
+
445
+ example:
446
+
447
+ ```ruby
448
+ vm.command.restart
449
+ vm.command.showvbanchat = true
450
+ ```
451
+
452
+ ### Device
453
+
454
+ - `ins` `outs` : Returns the number of input/output devices
455
+ - `input(i)` `output(i)` : Returns a hash of device properties for device[i]
456
+
457
+ example:
458
+
459
+ ```ruby
460
+ vm.run { (0...vm.device.ins).each { puts vm.device.input(_1) } }
461
+ ```
462
+
463
+ ### FX
464
+
465
+ ### Fx.Reverb | Fx.Delay
466
+
467
+ The following attributes are available:
468
+
469
+ - `on`: boolean
470
+ - `ab`: boolean
471
+
472
+ example:
473
+
474
+ ```ruby
475
+ vm.fx.reverb.on = true
476
+ vm.fx.delay.ab = true
477
+ ```
478
+
479
+ ### Patch
480
+
481
+ The following attributes are available:
482
+
483
+ - `postfadercomposite`: boolean
484
+ - `postfxinsert`: boolean
485
+
486
+ example:
487
+
488
+ ```ruby
489
+ vm.patch.postfxinsert = false
490
+ ```
491
+
492
+ ##### asio[i]
493
+
494
+ - `get()`: int
495
+ - `set(patch_in)`: int, valid range determined by connected device.
496
+
497
+ example:
498
+
499
+ ```ruby
500
+ vm.patch.asio[3].set(4)
501
+ ```
502
+
503
+ i, from 0 to 10
504
+
505
+ ##### A2[i] - A5[i]
506
+
507
+ - `get()`: int
508
+ - `set(patch_out)`: int, valid range determined by connected device.
509
+
510
+ example:
511
+
512
+ ```ruby
513
+ vm.patch.A3[5].set(3)
514
+ ```
515
+
516
+ i, from 0 to 8.
517
+
518
+ ##### composite[i]
519
+
520
+ - `get()`: int
521
+ - `set(channel)`: int, from 0 up to number of channels depending on version.
522
+
523
+ example:
524
+
525
+ ```ruby
526
+ vm.patch.composite[7].set(4)
527
+ ```
528
+
529
+ i, from 0 to 8.
530
+
531
+ ##### insert[i]
532
+
533
+ - `on`: boolean
534
+
535
+ example:
536
+
537
+ ```ruby
538
+ vm.patch.insert[18].on = true
539
+ ```
540
+
541
+ i, from 0 up to number of channels depending on version.
542
+
543
+ ### Option
544
+
545
+ The following attributes are available:
546
+
547
+ - `sr`: int
548
+ - `asiosr`: boolean
549
+ - `monitoronsel`: boolean
550
+ - `slidermode`: boolean
551
+
552
+ example:
553
+
554
+ ```ruby
555
+ vm.option.sr = 48_000
556
+ ```
557
+
558
+ #### Option.buffer
559
+
560
+ The following attributes are available:
561
+
562
+ - `mme`: int
563
+ - `wdm`: int
564
+ - `ks`: int
565
+ - `asio`: int
566
+
567
+ example:
568
+
569
+ ```ruby
570
+ vm.option.buffer.wdm = 512
571
+ ```
572
+
573
+ ##### delay[i]
574
+
575
+ - `get()`: int
576
+ - `set(delay)`: int, from 0 to 500
577
+
578
+ example:
579
+
580
+ ```ruby
581
+ vm.option.delay[4].set(30)
582
+ ```
583
+
584
+ i, from 0 up to 4.
585
+
586
+ ### Midi
587
+
588
+ The following attributes are available:
589
+
590
+ - `channel`: int, returns the midi channel
591
+ - `current`: int, returns the current (or most recently pressed) key
592
+
593
+ The following methods are available:
594
+
595
+ - `get(key)`: int, returns most recent velocity value for a key
596
+
597
+ example:
598
+
599
+ ```ruby
600
+ puts vm.midi.get(12)
601
+ ```
602
+
603
+ get may return nil if no value for requested key in midi cache
604
+
605
+ ### Multiple parameters
606
+
607
+ - `apply`
608
+ Set many strip/bus/macrobutton/vban parameters at once, for example:
609
+
610
+ ```ruby
611
+ vm.apply(
612
+ {
613
+ "strip-0" => {mute: true, gain: 3.2, A1: true},
614
+ "bus-3" => {gain: -3.2, eq: {on: true}},
615
+ "button-39" => {stateonly: true},
616
+ "vban-outstream-3" => {on: true, bit: 24}
617
+ }
618
+ )
619
+ ```
620
+
621
+ Or for each class you may do:
622
+
623
+ ```ruby
624
+ vm.strip[0].apply(mute: true, gain: 3.2, A1: true)
625
+ vm.vban.outstream[0].apply(on: true, name: "streamname", bit: 24)
626
+ ```
627
+
628
+ ## Config Files
629
+
630
+ `vm.apply_config(<configname>)`
631
+
632
+ You may load config files in TOML format.
633
+ Three example configs have been included with the package. Remember to save
634
+ current settings before loading a config. To set one you may do:
635
+
636
+ ```ruby
637
+ require "voicemeeter"
638
+ Voicemeeter::Remote.new(:banana).run { |vm| vm.apply_config(:example) }
639
+ ```
640
+
641
+ will load a config file at mydir/configs/banana/example.toml for Voicemeeter Banana.
642
+
643
+ ## Events
644
+
645
+ By default, NO events listened for.
646
+
647
+ Use keyword args `pdirty`, `mdirty`, `midi`, `ldirty` to initialize event updates.
648
+
649
+ example:
650
+
651
+ ```ruby
652
+ require 'voicemeeter'
653
+ # Set updates to occur every 50ms
654
+ # Listen for level updates
655
+ Voicemeeter::Remote.new(:banana, ratelimit: 0.05, ldirty: true).run do
656
+ ...
657
+ ```
658
+
659
+ #### `vm.on`
660
+
661
+ Use the `on` method to register blocks on the vm object to be called back later.
662
+
663
+ example:
664
+
665
+ ```ruby
666
+ # register a block with the on method
667
+ class App():
668
+ def initialize(vm)
669
+ @vm = vm
670
+ @vm.on :pdirty do
671
+ ...
672
+ end
673
+ ```
674
+
675
+ #### `vm.event`
676
+
677
+ Use the event class to toggle updates as necessary.
678
+
679
+ The following attributes are available:
680
+
681
+ - `pdirty`: boolean
682
+ - `mdirty`: boolean
683
+ - `midi`: boolean
684
+ - `ldirty`: boolean
685
+
686
+ example:
687
+
688
+ ```ruby
689
+ vm.event.ldirty = true
690
+
691
+ vm.event.pdirty = false
692
+ ```
693
+
694
+ Or add, remove an array of events.
695
+
696
+ The following methods are available:
697
+
698
+ - `add(events)`
699
+ - `remove(events)`
700
+ - `get`
701
+
702
+ example:
703
+
704
+ ```ruby
705
+ vm.event.add(%w[pdirty mdirty midi ldirty])
706
+
707
+ vm.event.remove(%w[pdirty mdirty midi ldirty])
708
+
709
+ # get a list of currently subscribed
710
+ p vm.event.get
711
+ ```
712
+
713
+ ## `Voicemeeter Module`
714
+
715
+ ### Remote class
716
+
717
+ #### Voicemeeter::Remote
718
+
719
+ You may pass the following optional keyword arguments:
720
+
721
+ - `sync`: boolean=false, force the getters to wait for dirty parameters to clear. For most cases leave this as false.
722
+ - `ratelimit`: float=0.033, how often to check for updates in ms.
723
+ - `pdirty`: boolean=true, parameter updates
724
+ - `mdirty`: boolean=true, macrobutton updates
725
+ - `midi`: boolean=true, midi updates
726
+ - `ldirty`: boolean=false, level updates
727
+
728
+ Access to lower level Getters and Setters are provided with these functions:
729
+
730
+ - `vm.get(param, string=false)`: For getting the value of any parameter. Set string to true if getting a property value expected to return a string.
731
+ - `vm.set(param, value)`: For setting the value of any parameter.
732
+
733
+ Access to lower level polling functions are provided with these functions:
734
+
735
+ - `vm.pdirty?`: Returns true iff a parameter has been updated.
736
+ - `vm.mdirty?`: Returns true iff a macrobutton has been updated.
737
+
738
+ example:
739
+
740
+ ```ruby
741
+ vm.get("Strip[2].Mute")
742
+ vm.set("Strip[4].Label", "stripname")
743
+ vm.set("Strip[0].Gain", -3.6)
744
+ ```
745
+
746
+ ### Errors
747
+
748
+ - `Errors::VMError`: Error raised when general errors occur.
749
+ - `Errors::VMCAPIError`: Error raised when the C-API returns error values.
750
+ - Error codes are stored in {Error Class}.code. For a full list of error codes [check the VoicemeeterRemote header file][voicemeeter remote header].
751
+
752
+ ### Logging
753
+
754
+ To enable logging set an environmental variable `VM_LOG_LEVEL` to the appropriate level.
755
+
756
+ example in powershell:
757
+
758
+ ```powershell
759
+ $env:VM_LOG_LEVEL="DEBUG"
760
+ ```
761
+
762
+ ### Tests
763
+
764
+ To run all tests:
765
+
766
+ ```
767
+ Bundle exec rake
768
+ ```
769
+
770
+ ### Official Documentation
771
+
772
+ - [Voicemeeter Remote C API](https://github.com/onyx-and-iris/Voicemeeter-SDK/blob/update-docs/VoicemeeterRemoteAPI.pdf)
773
+
774
+ [license]: https://github.com/onyx-and-iris/voicemeeter-rb/blob/dev/LICENSE
775
+ [voicemeeter remote header]: https://github.com/onyx-and-iris/Voicemeeter-SDK/blob/update-docs/VoicemeeterRemote.h