├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md └── src ├── app.vrmanifest ├── config.json ├── main.py ├── requirements.txt ├── setup.py ├── tinyoscquery ├── query.py ├── queryservice.py ├── shared │ ├── __init__.py │ └── node.py └── utility.py └── voicemeeter ├── __init__.py ├── driver.py ├── errors.py ├── input.py ├── kinds.py ├── output.py ├── profiles.py ├── remote.py ├── strip.py └── util.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .venv/ 2 | __pycache__/ 3 | build/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VRCMeeter [![Github All Releases](https://img.shields.io/github/downloads/i5ucc/VRCMeeter/total.svg)](https://github.com/I5UCC/VRCMeeter/releases/latest) Buy Me a Coffee at ko-fi.com (Superseded by [SteaMeeter](https://github.com/I5UCC/SteaMeeter)) 2 | 3 | 4 | Control Voicemeeter's Virtual Inputs/Outputs in VRChat via OSC. 5 | 6 | https://github.com/I5UCC/VRCVoiceMeeterControl/assets/43730681/d8f16c9c-84de-4aa2-820f-de59572e04fa 7 | 8 | # Configuration / Usage 9 | 10 | All of the configuration is done in the `config.json` file. 11 | Currently this program only supports controlling gains of any input/output slider in Voicemeeter and loading profiles created in Voicemeeter. 12 | 13 | | Option | Explanation | 14 | | ------ | ----------- | 15 | | ip | The IP used to send data to. | 16 | | port | The Port used to send data to. | 17 | | server_port | The Port used to recieve data from. When 0, a port is automatically chosen. | 18 | | http_port | Port used to host the zeroconf server for discovery by vrchat. When 0, a port is a port is automatically chosen. | 19 | | min_gain | ***Minimum*** gain for any slider in Voicemeeter. -60 is the default and doesn't go lower in Voicemeeter | 20 | | max_gain | ***Maximum*** gain for any slider in Voicemeeter. 0 is the default but you can change it to up to 12 if you wish so. | 21 | | voicemeeter_type | The type of voicemeeter application that you are using. Can be either `basic`, `banana` or `potato` | 22 | | strips_in | Indices of ***input*** strips to bind to a VRChat parameter. If left empty, every available strip gets bound. If the only value is -1, no strips will be bound. | 23 | | strips_out | Indices of ***output*** strips to bind to a VRChat parameter. If left empty, every available strip gets bound. If the only value is -1, no strips will be bound. | 24 | | profiles | Array of Profiles that can be bound to VRChat parameters. Use the full name of the xml file, not the path, and have the xml file placed in the same folder as the executable. | 25 | | startup_profile | Profile to load at the startup of this program, leave empty if not needed. | 26 | 27 | After setting up the programs settings to your liking, you need to add the bound parameters to VRChat. Here is an example on how that works: 28 | I only want to control the trips 5, 6 and 7 in Voicemeeter Potato: 29 | 30 | ![image](https://github.com/I5UCC/VRCMeeter/assets/43730681/47da8ace-ade1-42e0-ac98-54ff8b343d2e) 31 | 32 | As i am using Voicemeeter Potato, i set the `voicemeeter_type` setting in the `config.json` file to potato: 33 | 34 | `"voicemeeter_type": "potato",` 35 | 36 | So we add those to the `config.json` file, and set the stips_out to -1, as we dont need them: 37 | 38 | ``` 39 | "strips_in": [5, 6, 7], 40 | "strips_out": [-1], 41 | ``` 42 | 43 | I also want to be able to load one of my profiles called vr.xml, so i add that to my config: 44 | 45 | `"profiles": ["vr.xml"],` 46 | 47 | Now after running the program, it shows me the parameters it has bound now: 48 | 49 | ![image](https://github.com/I5UCC/VRCMeeter/assets/43730681/bfc8479a-507b-4ddc-8dc8-1324c001b7f0) 50 | 51 | Now i need to add these Parameters to my VRChat avatar. To do that you open the avatars expression parameters and add as many lines as you need: 52 | 53 | ![image](https://github.com/I5UCC/VRCMeeter/assets/43730681/ffe05722-8763-426a-9482-a2ac45ef9ff2) 54 | 55 | If you don't want to waste Parameter space of your avatar, make sure they are not synced (last checkbox on the right unticked).
56 | For parameters that control the gain of a strip, choose the parameter type ***float*** for anything else choose ***bool*** 57 | 58 | Now you need to add these Parameters to your expression Menu: 59 | 60 | ![image](https://github.com/I5UCC/VRCMeeter/assets/43730681/71fe16ab-38eb-43bb-aa4e-935e1affa6cb) 61 | 62 | For every parameter that is a ***bool***, set the type to ***button***, for every ***float*** parameter set it to ***radial puppet*** 63 | 64 | Aaaaaand you are done! You best reset your OSC Configuration after updating an existing avatar with those parameters. You can do that as follows: 65 | - Close VRChat. 66 | - Open 'Run' in Windows (Windows Key + R) 67 | - Type in `%APPDATA%\..\LocalLow\VRChat\VRChat\OSC` 68 | - Delete the folders that start with 'usr_*'. 69 | - Startup VRChat again and it should work. 70 | -------------------------------------------------------------------------------- /src/app.vrmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "source": "builtin", 3 | "applications": [ 4 | { 5 | "app_key": "i5ucc.VRCMeeter", 6 | "launch_type": "binary", 7 | "binary_path_windows": "./VRCMeeter_NoConsole.exe", 8 | "is_dashboard_overlay": true, 9 | 10 | "strings": { 11 | "en_us": { 12 | "name": "VRCMeeter", 13 | "description": "Lets you control Voicemeeter from within VRChat over OSC" 14 | } 15 | } 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /src/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "ip": "127.0.0.1", 3 | "port": 9000, 4 | "server_port": 0, 5 | "http_port": 0, 6 | "min_gain": -60, 7 | "max_gain": 0, 8 | "voicemeeter_type": "potato", 9 | "strips_in": [], 10 | "strips_out": [], 11 | "profiles": [], 12 | "startup_profile": "" 13 | } -------------------------------------------------------------------------------- /src/main.py: -------------------------------------------------------------------------------- 1 | import voicemeeter 2 | import json 3 | import os 4 | import sys 5 | import time 6 | import traceback 7 | import ctypes 8 | import zeroconf 9 | from pythonosc import dispatcher, osc_server, udp_client 10 | from tinyoscquery.queryservice import OSCQueryService 11 | from tinyoscquery.utility import get_open_tcp_port, get_open_udp_port, check_if_tcp_port_open, check_if_udp_port_open 12 | from tinyoscquery.query import OSCQueryBrowser, OSCQueryClient 13 | from psutil import process_iter 14 | from threading import Thread, Timer 15 | import logging 16 | import openvr 17 | 18 | 19 | class RepeatedTimer(object): 20 | def __init__(self, interval: float, function, *args, **kwargs): 21 | self._timer: Timer = None 22 | self.interval = interval 23 | self.function = function 24 | self.args = args 25 | self.kwargs = kwargs 26 | self.is_running: bool = False 27 | self.start() 28 | 29 | def _run(self): 30 | self.is_running = False 31 | self.start() 32 | self.function(*self.args, **self.kwargs) 33 | 34 | def start(self): 35 | if not self.is_running: 36 | self._timer = Timer(self.interval, self._run) 37 | self._timer.start() 38 | self.is_running = True 39 | 40 | def stop(self): 41 | self._timer.cancel() 42 | self.is_running = False 43 | 44 | 45 | def get_absolute_path(relative_path, script_path=__file__) -> str: 46 | """Gets absolute path from relative path""" 47 | base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(script_path))) 48 | return os.path.join(base_path, relative_path) 49 | 50 | 51 | def get_float_from_voicemeeter_gain(g): 52 | """Maps a gain value between min_gain and max_gain to a float from 0.0 to 1.0.""" 53 | return (g - MIN_GAIN) / (MAX_GAIN - MIN_GAIN) 54 | 55 | 56 | def get_voicemeeter_gain_from_float(f): 57 | """Maps a float from 0.0 to 1.0 to a gain value between min_gain and max_gain.""" 58 | return f * (MAX_GAIN - MIN_GAIN) + MIN_GAIN 59 | 60 | 61 | def is_vrchat_running() -> bool: 62 | """Checks if VRChat is running.""" 63 | _proc_name = "VRChat.exe" if os.name == 'nt' else "VRChat" 64 | return _proc_name in (p.name() for p in process_iter()) 65 | 66 | 67 | def wait_get_oscquery_client(): 68 | service_info = None 69 | logging.info("Waiting for VRChat to be discovered.") 70 | while service_info is None: 71 | browser = OSCQueryBrowser() 72 | time.sleep(2) # Wait for discovery 73 | service_info = browser.find_service_by_name("VRChat") 74 | logging.info("VRChat discovered!") 75 | client = OSCQueryClient(service_info) 76 | logging.info("Waiting for VRChat to be ready.") 77 | while client.query_node(AVATAR_CHANGE_PARAMETER) is None: 78 | time.sleep(2) 79 | logging.info("VRChat ready!") 80 | return client 81 | 82 | 83 | def set_gain_variable_in(addr, value): 84 | global gains_in, changed 85 | strip = int(addr.split('_')[-1]) 86 | gain = get_voicemeeter_gain_from_float(float(value)) 87 | gains_in[strip] = round(gain, 1) 88 | changed = True 89 | 90 | 91 | def set_gain_variable_out(addr, value): 92 | global gains_out, changed 93 | strip = int(addr.split('_')[-1]) 94 | gain = get_voicemeeter_gain_from_float(float(value)) 95 | gains_out[strip] = round(gain, 1) 96 | changed = True 97 | 98 | 99 | def set_gains(): 100 | global changed 101 | global vmr, gains_in 102 | 103 | if not changed: 104 | return 105 | 106 | for strip in STRIPS_IN: 107 | if round(vmr.inputs[strip].gain, 1) == gains_in[strip]: 108 | continue 109 | logging.info(f"Setting gain for strip {strip} to {gains_in[strip]}") 110 | vmr.inputs[strip].gain = gains_in[strip] 111 | for strip in STRIPS_OUT: 112 | if round(vmr.outputs[strip].gain, 1) == gains_out[strip]: 113 | continue 114 | logging.info(f"Setting gain for strip {strip} to {gains_out[strip]}") 115 | vmr.outputs[strip].gain = gains_out[strip] 116 | changed = False 117 | 118 | 119 | def set_profile(addr, value): 120 | global vmr 121 | if type(addr) is int: 122 | logging.info(f"Setting profile to {PROFILES[addr]}") 123 | vmr.load(get_absolute_path(PROFILES[addr])) 124 | else: 125 | logging.info(f"Setting profile to {addr}") 126 | vmr.load(get_absolute_path(addr)) 127 | time.sleep(1) 128 | avatar_change(None, None) 129 | 130 | 131 | def avatar_change(addr, value): 132 | global vmr 133 | 134 | logging.info("Avatar changed/reset...") 135 | 136 | for strip in STRIPS_IN: 137 | osc_client.send_message(f"{PARAMETER_PREFIX_IN}gain_{strip}", get_float_from_voicemeeter_gain(vmr.inputs[strip].gain)) 138 | for strip in STRIPS_OUT: 139 | osc_client.send_message(f"{PARAMETER_PREFIX_OUT}gain_{strip}", get_float_from_voicemeeter_gain(vmr.outputs[strip].gain)) 140 | 141 | 142 | def osc_server_serve(): 143 | logging.info(f"Starting OSC client on {OSC_SERVER_IP}:{OSC_SERVER_PORT}:{HTTP_PORT}") 144 | server.serve_forever(2) 145 | 146 | 147 | def exit(): 148 | logging.info("Exiting...") 149 | if vmr: 150 | vmr.logout() 151 | if update_timer: 152 | update_timer.stop() 153 | if oscqs: 154 | oscqs.stop() 155 | sys.exit(0) 156 | 157 | 158 | logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S', handlers=[logging.StreamHandler()]) 159 | 160 | conf = json.load(open(get_absolute_path('config.json'))) 161 | changed = False 162 | gains_in = {} 163 | gains_out = {} 164 | osc_client: udp_client.SimpleUDPClient = None 165 | vmr: voicemeeter.remote = None 166 | server: osc_server.ThreadingOSCUDPServer = None 167 | server_thread: Thread = None 168 | qclient: OSCQueryClient = None 169 | oscqs: OSCQueryService = None 170 | update_timer: RepeatedTimer = None 171 | 172 | KIND = conf['voicemeeter_type'] 173 | STRIPS_IN = conf['strips_in'] 174 | STRIPS_OUT = conf['strips_out'] 175 | PROFILES = conf['profiles'] 176 | OSC_CLIENT_PORT = conf["port"] 177 | OSC_SERVER_PORT = conf['server_port'] 178 | OSC_SERVER_IP = conf['ip'] 179 | HTTP_PORT = conf['http_port'] 180 | MIN_GAIN = conf['min_gain'] 181 | MAX_GAIN = conf['max_gain'] 182 | AVATAR_CHANGE_PARAMETER = "/avatar/change" 183 | PARAMETER_RESTART = "/avatar/parameters/vm_restart" 184 | PARAMETER_PREFIX_IN = "/avatar/parameters/vm_in_" 185 | PARAMETER_PREFIX_OUT = "/avatar/parameters/vm_out_" 186 | PARAMETER_PREFIX_PROFILE = "/avatar/parameters/vm_profile_" 187 | 188 | if OSC_SERVER_PORT != 9001: 189 | logging.info("OSC Server port is not default, testing port availability and advertising OSCQuery endpoints") 190 | if OSC_SERVER_PORT <= 0 or not check_if_udp_port_open(OSC_SERVER_PORT): 191 | OSC_SERVER_PORT = get_open_udp_port() 192 | if HTTP_PORT <= 0 or not check_if_tcp_port_open(HTTP_PORT): 193 | HTTP_PORT = OSC_SERVER_PORT if check_if_tcp_port_open(OSC_SERVER_PORT) else get_open_tcp_port() 194 | else: 195 | logging.info("OSC Server port is default.") 196 | 197 | try: 198 | application = openvr.init(openvr.VRApplication_Utility) 199 | openvr.VRApplications().addApplicationManifest(get_absolute_path("app.vrmanifest")) 200 | logging.info("Added VRManifest.") 201 | vmr = voicemeeter.remote(KIND) 202 | vmr.login() 203 | logging.info("Logged in to Voicemeeter.") 204 | if conf["startup_profile"] is not None and conf["startup_profile"] != "": 205 | set_profile(conf["startup_profile"], None) 206 | except Exception as e: 207 | if os.name == "nt": 208 | ctypes.windll.user32.MessageBoxW(0, traceback.format_exc(), "VRCMeeter - Error", 0) 209 | logging.error(traceback.format_exc()) 210 | exit() 211 | 212 | if STRIPS_IN is None or len(STRIPS_IN) == 1 and STRIPS_IN[0] == -1: 213 | STRIPS_IN = {} 214 | elif len(STRIPS_IN) == 0: 215 | STRIPS_IN = [i for i in range(len(vmr.inputs))] 216 | 217 | if STRIPS_OUT is None or len(STRIPS_OUT) == 1 and STRIPS_OUT[0] == -1: 218 | STRIPS_OUT = {} 219 | elif len(STRIPS_OUT) == 0: 220 | STRIPS_OUT = [i for i in range(len(vmr.outputs))] 221 | 222 | for strip in STRIPS_IN: 223 | gains_in[strip] = round(vmr.inputs[strip].gain, 1) 224 | logging.debug(f"IN-{strip} gain: {gains_in[strip]}") 225 | for strip in STRIPS_OUT: 226 | gains_out[strip] = round(vmr.outputs[strip].gain, 1) 227 | logging.debug(f"OUT-{strip} gain: {gains_out[strip]}") 228 | 229 | try: 230 | osc_client = udp_client.SimpleUDPClient(OSC_SERVER_IP, OSC_CLIENT_PORT) 231 | 232 | disp = dispatcher.Dispatcher() 233 | disp.map(AVATAR_CHANGE_PARAMETER, avatar_change) 234 | disp.map(PARAMETER_RESTART, lambda addr, value: vmr.restart()) 235 | logging.info(f"Bound restart to {PARAMETER_RESTART}") 236 | for i in range(len(PROFILES)): 237 | disp.map(f"{PARAMETER_PREFIX_PROFILE}{i}", lambda addr, value: set_profile(int(addr.split('_')[-1]), value)) 238 | logging.info(f"Bound profile {PROFILES[i]} to {PARAMETER_PREFIX_PROFILE}{i}") 239 | 240 | for strip in STRIPS_IN: 241 | disp.map(f"{PARAMETER_PREFIX_IN}gain_{strip}", set_gain_variable_in) 242 | logging.info(f"Bound IN-{strip} to {PARAMETER_PREFIX_IN}gain_{strip}") 243 | 244 | for strip in STRIPS_OUT: 245 | disp.map(f"{PARAMETER_PREFIX_OUT}gain_{strip}", set_gain_variable_out) 246 | logging.info(f"Bound OUT-{strip} to {PARAMETER_PREFIX_OUT}gain_{strip}") 247 | 248 | server = osc_server.BlockingOSCUDPServer((OSC_SERVER_IP, OSC_SERVER_PORT), disp) 249 | server_thread = Thread(target=osc_server_serve, daemon=True) 250 | server_thread.start() 251 | 252 | logging.info("Waiting for VRChat to start.") 253 | while not is_vrchat_running(): 254 | time.sleep(5) 255 | logging.info("VRChat started!") 256 | qclient = wait_get_oscquery_client() 257 | oscqs = OSCQueryService("VoicemeeterControl", HTTP_PORT, OSC_SERVER_PORT) 258 | oscqs.advertise_endpoint(AVATAR_CHANGE_PARAMETER, access="readwrite") 259 | oscqs.advertise_endpoint(PARAMETER_RESTART, access="readwrite") 260 | for i in range(len(PROFILES)): 261 | oscqs.advertise_endpoint(f"{PARAMETER_PREFIX_PROFILE}{i}", access="readwrite") 262 | 263 | for strip in STRIPS_IN: 264 | oscqs.advertise_endpoint(f"{PARAMETER_PREFIX_IN}gain_{strip}", access="readwrite") 265 | 266 | for strip in STRIPS_OUT: 267 | oscqs.advertise_endpoint(f"{PARAMETER_PREFIX_OUT}gain_{strip}", access="readwrite") 268 | 269 | 270 | avatar_change(None, None) 271 | 272 | update_timer = RepeatedTimer(0.3, set_gains) 273 | update_timer.start() 274 | 275 | while is_vrchat_running(): 276 | time.sleep(5) 277 | 278 | logging.info("VRChat closed, exiting.") 279 | exit() 280 | except OSError as e: 281 | if os.name == "nt": 282 | ctypes.windll.user32.MessageBoxW(0, "You can only bind to the port 9001 once.", "VRCMeeter - Error", 0) 283 | exit() 284 | except zeroconf._exceptions.NonUniqueNameException as e: 285 | logging.error("NonUniqueNameException, trying again...") 286 | os.execv(sys.executable, ['python'] + sys.argv) 287 | except KeyboardInterrupt: 288 | exit() 289 | except Exception as e: 290 | if os.name == "nt": 291 | ctypes.windll.user32.MessageBoxW(0, traceback.format_exc(), "VRCMeeter - Unexpected Error", 0) 292 | logging.error(traceback.format_exc()) 293 | exit() 294 | -------------------------------------------------------------------------------- /src/requirements.txt: -------------------------------------------------------------------------------- 1 | python_osc 2 | zeroconf 3 | requests 4 | psutil 5 | toml 6 | openvr -------------------------------------------------------------------------------- /src/setup.py: -------------------------------------------------------------------------------- 1 | from cx_Freeze import setup, Executable 2 | 3 | packages = ["pythonosc", "psutil", "zeroconf", "json", "threading", "time", "os", "sys", "ctypes", "traceback"] 4 | file_include = ["config.json", "app.vrmanifest"] 5 | 6 | build_exe_options = {"packages": packages, "include_files": file_include, 'include_msvcr': True, 'optimize': 2} 7 | 8 | setup( 9 | name="VRCMeeter", 10 | version="0.2", 11 | description="Lets you control Voicemeeter from within VRChat over OSC", 12 | options={"build_exe": build_exe_options}, 13 | executables=[Executable("main.py", target_name="VRCMeeter.exe", base=False), Executable("main.py", target_name="VRCMeeter_NoConsole.exe", base="Win32GUI")], 14 | ) -------------------------------------------------------------------------------- /src/tinyoscquery/query.py: -------------------------------------------------------------------------------- 1 | import time 2 | from zeroconf import ServiceBrowser, ServiceInfo, ServiceListener, Zeroconf 3 | import requests 4 | 5 | from .shared.node import OSCQueryNode, OSC_Type_String_to_Python_Type, OSCAccess, OSCHostInfo 6 | 7 | class OSCQueryListener(ServiceListener): 8 | 9 | def __init__(self) -> None: 10 | self.osc_services = {} 11 | self.oscjson_services = {} 12 | 13 | super().__init__() 14 | 15 | def remove_service(self, zc: 'Zeroconf', type_: str, name: str) -> None: 16 | if name in self.osc_services: 17 | del self.osc_services[name] 18 | 19 | if name in self.oscjson_services: 20 | del self.oscjson_services[name] 21 | 22 | def add_service(self, zc: 'Zeroconf', type_: str, name: str) -> None: 23 | if type_ == '_osc._udp.local.': 24 | self.osc_services[name] = zc.get_service_info(type_, name) 25 | elif type_ == '_oscjson._tcp.local.': 26 | self.oscjson_services[name] = zc.get_service_info(type_, name) 27 | 28 | def update_service(self, zc: 'Zeroconf', type_: str, name: str) -> None: 29 | if type_ == '_osc._udp.local.': 30 | self.osc_services[name] = zc.get_service_info(type_, name) 31 | elif type_ == '_oscjson._tcp.local.': 32 | self.oscjson_services[name] = zc.get_service_info(type_, name) 33 | 34 | 35 | class OSCQueryBrowser(object): 36 | def __init__(self) -> None: 37 | self.listener = OSCQueryListener() 38 | self.zc = Zeroconf() 39 | self.browser = ServiceBrowser(self.zc, ["_oscjson._tcp.local.", "_osc._udp.local."], self.listener) 40 | 41 | def get_discovered_osc(self): 42 | return [oscsvc[1] for oscsvc in self.listener.osc_services.items()] 43 | 44 | def get_discovered_oscquery(self): 45 | return [oscjssvc[1] for oscjssvc in self.listener.oscjson_services.items()] 46 | 47 | def find_service_by_name(self, name): 48 | for svc in self.get_discovered_oscquery(): 49 | client = OSCQueryClient(svc) 50 | if name in client.get_host_info().name: 51 | return svc 52 | 53 | return None 54 | 55 | def find_nodes_by_endpoint_address(self, address) -> list[tuple[ServiceInfo, OSCHostInfo, OSCQueryNode]]: 56 | svcs = [] 57 | for svc in self.get_discovered_oscquery(): 58 | client = OSCQueryClient(svc) 59 | hi = client.get_host_info() 60 | if hi is None: 61 | continue 62 | node = client.query_node(address) 63 | if node is not None: 64 | svcs.append((svc, hi, node)) 65 | 66 | return svcs 67 | 68 | 69 | class OSCQueryClient(object): 70 | def __init__(self, service_info) -> None: 71 | if not isinstance(service_info, ServiceInfo): 72 | raise Exception("service_info isn't a ServiceInfo class!") 73 | 74 | if service_info.type != "_oscjson._tcp.local.": 75 | raise Exception("service_info does not represent an OSCQuery service!") 76 | 77 | self.service_info = service_info 78 | self.last_json = None 79 | 80 | def _get_query_root(self): 81 | return f"http://{self._get_ip_str()}:{self.service_info.port}" 82 | 83 | def _get_ip_str(self): 84 | ip_str = '.'.join([str(int(num)) for num in self.service_info.addresses[0]]) 85 | return ip_str 86 | 87 | def query_node(self, node="/"): 88 | url = self._get_query_root() + node 89 | r = None 90 | try: 91 | r = requests.get(url) 92 | except Exception as ex: 93 | print("Error querying node...", ex) 94 | if r is None: 95 | return None 96 | 97 | if r.status_code == 404: 98 | return None 99 | 100 | if r.status_code != 200: 101 | raise Exception("Node query error: (HTTP", r.status_code, ") ", r.content) 102 | 103 | self.last_json = r.json() 104 | 105 | return self._make_node_from_json(self.last_json) 106 | 107 | 108 | def get_host_info(self): 109 | url = self._get_query_root() + "/HOST_INFO" 110 | r = None 111 | try: 112 | r = requests.get(url) 113 | except Exception as ex: 114 | #print("Error querying HOST_INFO...", ex) 115 | pass 116 | if r is None: 117 | return None 118 | 119 | if r.status_code != 200: 120 | raise Exception("Node query error: (HTTP", r.status_code, ") ", r.content) 121 | 122 | json = r.json() 123 | hi = OSCHostInfo(json["NAME"], json['EXTENSIONS']) 124 | if 'OSC_IP' in json: 125 | hi.osc_ip = json["OSC_IP"] 126 | else: 127 | hi.osc_ip = self._get_ip_str() 128 | 129 | if 'OSC_PORT' in json: 130 | hi.osc_port = json['OSC_PORT'] 131 | else: 132 | hi.osc_port = self.service_info.port 133 | 134 | if 'OSC_TRANSPORT' in json: 135 | hi.osc_transport = json['OSC_TRANSPORT'] 136 | else: 137 | hi.osc_transport = "UDP" 138 | 139 | return hi 140 | 141 | def _make_node_from_json(self, json): 142 | newNode = OSCQueryNode() 143 | 144 | if "CONTENTS" in json: 145 | subNodes = [] 146 | for subNode in json["CONTENTS"]: 147 | subNodes.append(self._make_node_from_json(json["CONTENTS"][subNode])) 148 | newNode.contents = subNodes 149 | 150 | # This *should* be required but some implementations don't have it... 151 | if "FULL_PATH" in json: 152 | newNode.full_path = json["FULL_PATH"] 153 | 154 | if "TYPE" in json: 155 | newNode.type_ = OSC_Type_String_to_Python_Type(json["TYPE"]) 156 | 157 | if "DESCRIPTION" in json: 158 | newNode.description = json["DESCRIPTION"] 159 | 160 | if "ACCESS" in json: 161 | newNode.access = OSCAccess(json["ACCESS"]) 162 | 163 | if "VALUE" in json: 164 | newNode.value = [] 165 | # This should always be an array... throw an exception here? 166 | if not isinstance(json['VALUE'], list): 167 | raise Exception("OSCQuery JSON Value is not List / Array? Out-of-spec?") 168 | 169 | for idx, v in enumerate(json["VALUE"]): 170 | # According to the spec, if there is not yet a value, the return will be an empty JSON object 171 | if isinstance(v, dict) and not v: 172 | # FIXME does this apply to all values in the value array always...? I assume it does here 173 | newNode.value = [] 174 | break 175 | else: 176 | newNode.value.append(newNode.type_[idx](v)) 177 | 178 | 179 | return newNode 180 | 181 | 182 | 183 | 184 | if __name__ == "__main__": 185 | browser = OSCQueryBrowser() 186 | time.sleep(2) # Wait for discovery 187 | 188 | for service_info in browser.get_discovered_oscquery(): 189 | client = OSCQueryClient(service_info) 190 | 191 | # Find host info 192 | host_info = client.get_host_info() 193 | print(f"Found OSC Host: {host_info.name} with ip {host_info.osc_ip}:{host_info.osc_port}") 194 | 195 | # Query a node and print its value 196 | node = client.query_node("/test/node") 197 | print(f"Node is a {node.type_} with value {node.value}") 198 | 199 | 200 | -------------------------------------------------------------------------------- /src/tinyoscquery/queryservice.py: -------------------------------------------------------------------------------- 1 | from zeroconf import ServiceInfo, Zeroconf 2 | from http.server import SimpleHTTPRequestHandler, HTTPServer 3 | from .shared.node import OSCQueryNode, OSCHostInfo, OSCAccess 4 | import json, threading 5 | 6 | 7 | class OSCQueryService(object): 8 | """ 9 | A class providing an OSCQuery service. Automatically sets up a oscjson http server and advertises the oscjson server and osc server on zeroconf. 10 | 11 | Attributes 12 | ---------- 13 | serverName : str 14 | Name of your OSC Service 15 | httpPort : int 16 | Desired TCP port number for the oscjson HTTP server 17 | oscPort : int 18 | Desired UDP port number for the osc server 19 | """ 20 | 21 | def __init__(self, serverName, httpPort, oscPort, oscIp="127.0.0.1") -> None: 22 | self.serverName = serverName 23 | self.httpPort = httpPort 24 | self.oscPort = oscPort 25 | self.oscIp = oscIp 26 | 27 | self.root_node = OSCQueryNode("/", description="root node") 28 | self.host_info = OSCHostInfo(serverName, {"ACCESS":True,"CLIPMODE":False,"RANGE":True,"TYPE":True,"VALUE":True}, 29 | self.oscIp, self.oscPort, "UDP") 30 | 31 | self._zeroconf = Zeroconf() 32 | self._startOSCQueryService() 33 | self._advertiseOSCService() 34 | self.http_server = OSCQueryHTTPServer(self.root_node, self.host_info, ('', self.httpPort), OSCQueryHTTPHandler) 35 | self.http_thread = threading.Thread(target=self._startHTTPServer) 36 | self.http_thread.start() 37 | 38 | def stop(self): 39 | self.http_server.shutdown() 40 | 41 | def add_node(self, node): 42 | self.root_node.add_child_node(node) 43 | 44 | def advertise_endpoint(self, address, value=None, access=OSCAccess.READWRITE_VALUE): 45 | new_node = OSCQueryNode(full_path=address, access=access) 46 | if value is not None: 47 | if not isinstance(value, list): 48 | new_node.value = [value] 49 | new_node.type_ = [type(value)] 50 | else: 51 | new_node.value = value 52 | new_node.type_ = [type(v) for v in value] 53 | self.add_node(new_node) 54 | 55 | def _startOSCQueryService(self): 56 | oscqsDesc = {'txtvers': 1} 57 | oscqsInfo = ServiceInfo("_oscjson._tcp.local.", "%s._oscjson._tcp.local." % self.serverName, self.httpPort, 58 | 0, 0, oscqsDesc, "%s.oscjson.local." % self.serverName, addresses=["127.0.0.1"]) 59 | self._zeroconf.register_service(oscqsInfo) 60 | 61 | 62 | def _startHTTPServer(self): 63 | self.http_server.serve_forever() 64 | 65 | def _advertiseOSCService(self): 66 | oscDesc = {'txtvers': 1} 67 | oscInfo = ServiceInfo("_osc._udp.local.", "%s._osc._udp.local." % self.serverName, self.oscPort, 68 | 0, 0, oscDesc, "%s.osc.local." % self.serverName, addresses=["127.0.0.1"]) 69 | 70 | self._zeroconf.register_service(oscInfo) 71 | 72 | 73 | class OSCQueryHTTPServer(HTTPServer): 74 | def __init__(self, root_node, host_info, server_address: tuple[str, int], RequestHandlerClass, bind_and_activate: bool = ...) -> None: 75 | super().__init__(server_address, RequestHandlerClass, bind_and_activate) 76 | self.root_node = root_node 77 | self.host_info = host_info 78 | 79 | 80 | class OSCQueryHTTPHandler(SimpleHTTPRequestHandler): 81 | def do_GET(self) -> None: 82 | if 'HOST_INFO' in self.path: 83 | self.send_response(200) 84 | self.send_header("Content-type", "text/json") 85 | self.end_headers() 86 | self.wfile.write(bytes(str(self.server.host_info.to_json()), 'utf-8')) 87 | return 88 | node = self.server.root_node.find_subnode(self.path) 89 | if node is None: 90 | self.send_response(404) 91 | self.send_header("Content-type", "text/json") 92 | self.end_headers() 93 | self.wfile.write(bytes("OSC Path not found", 'utf-8')) 94 | else: 95 | self.send_response(200) 96 | self.send_header("Content-type", "text/json") 97 | self.end_headers() 98 | self.wfile.write(bytes(str(node.to_json()), 'utf-8')) 99 | 100 | def log_message(self, format, *args): 101 | pass 102 | 103 | -------------------------------------------------------------------------------- /src/tinyoscquery/shared/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/I5UCC/VRCMeeter/1742e279b0674f4f4b302460fe8d1830083932e8/src/tinyoscquery/shared/__init__.py -------------------------------------------------------------------------------- /src/tinyoscquery/shared/node.py: -------------------------------------------------------------------------------- 1 | from enum import IntEnum 2 | import json 3 | from json import JSONEncoder 4 | 5 | class OSCNodeEncoder(JSONEncoder): 6 | def default(self, o): 7 | if isinstance(o, OSCQueryNode): 8 | obj_dict = {} 9 | for k, v in vars(o).items(): 10 | if v is None: 11 | continue 12 | if k.lower() == "type_": 13 | obj_dict["TYPE"] = Python_Type_List_to_OSC_Type(v) 14 | if k == "contents": 15 | obj_dict["CONTENTS"] = {} 16 | for subNode in v: 17 | if subNode.full_path is not None: 18 | obj_dict["CONTENTS"][subNode.full_path.split("/")[-1]] = subNode 19 | else: 20 | continue 21 | else: 22 | obj_dict[k.upper()] = v 23 | 24 | # FIXME: I missed something, so here's a hack! 25 | 26 | if "TYPE_" in obj_dict: 27 | del obj_dict["TYPE_"] 28 | return obj_dict 29 | 30 | if isinstance(o, type): 31 | return Python_Type_List_to_OSC_Type([o]) 32 | 33 | if isinstance(o, OSCHostInfo): 34 | obj_dict = {} 35 | for k, v in vars(o).items(): 36 | if v is None: 37 | continue 38 | obj_dict[k.upper()] = v 39 | return obj_dict 40 | 41 | return json.JSONEncoder.default(self, o) 42 | 43 | class OSCAccess(IntEnum): 44 | NO_VALUE = 0 45 | READONLY_VALUE = 1 46 | WRITEONLY_VALUE = 2 47 | READWRITE_VALUE = 3 48 | 49 | class OSCQueryNode(): 50 | def __init__(self, full_path=None, contents=None, type_=None, access=None, description=None, value=None, host_info=None): 51 | self.contents = contents 52 | self.full_path = full_path 53 | self.access = access 54 | self.type_ = type_ 55 | # Value is always an array! 56 | self.value = value 57 | self.description = description 58 | self.host_info = host_info 59 | 60 | 61 | def find_subnode(self, full_path): 62 | if self.full_path == full_path: 63 | return self 64 | 65 | foundNode = None 66 | if self.contents is None: 67 | return None 68 | 69 | for subNode in self.contents: 70 | foundNode = subNode.find_subnode(full_path) 71 | if foundNode is not None: 72 | break 73 | 74 | return foundNode 75 | 76 | def add_child_node(self, child): 77 | if child == self: 78 | return 79 | 80 | path_split = child.full_path.rsplit("/",1) 81 | if len(path_split) < 2: 82 | raise Exception("Tried to add child node with invalid full path!") 83 | 84 | parent_path = path_split[0] 85 | 86 | if parent_path == '': 87 | parent_path = "/" 88 | 89 | parent = self.find_subnode(parent_path) 90 | 91 | if parent is None: 92 | parent = OSCQueryNode(parent_path) 93 | self.add_child_node(parent) 94 | 95 | 96 | if parent.contents is None: 97 | parent.contents = [] 98 | parent.contents.append(child) 99 | 100 | 101 | def to_json(self): 102 | return json.dumps(self, cls=OSCNodeEncoder) 103 | 104 | 105 | def __iter__(self): 106 | yield self 107 | if self.contents is not None: 108 | for subNode in self.contents: 109 | yield from subNode 110 | 111 | def __str__(self) -> str: 112 | return f'' 113 | 114 | class OSCHostInfo(): 115 | def __init__(self, name, extensions, osc_ip=None, osc_port=None, osc_transport=None, ws_ip=None, ws_port=None) -> None: 116 | self.name = name 117 | self.osc_ip = osc_ip 118 | self.osc_port = osc_port 119 | self.osc_transport = osc_transport 120 | self.ws_ip = ws_ip 121 | self.ws_port = ws_port 122 | self.extensions = extensions 123 | 124 | def to_json(self) -> str: 125 | return json.dumps(self, cls=OSCNodeEncoder) 126 | 127 | def __str__(self) -> str: 128 | return json.dumps(self, cls=OSCNodeEncoder) 129 | 130 | def OSC_Type_String_to_Python_Type(typestr): 131 | types = [] 132 | for typevalue in typestr: 133 | if typevalue == '': 134 | continue 135 | 136 | if typevalue == "i": 137 | types.append(int) 138 | elif typevalue == "f" or typevalue == "h" or typevalue == "d" or typevalue == "t": 139 | types.append(float) 140 | elif typevalue == "T" or typevalue == "F": 141 | types.append(bool) 142 | elif typevalue == "s": 143 | types.append(str) 144 | else: 145 | raise Exception(f"Unknown OSC type when converting! {typevalue} -> ???") 146 | 147 | 148 | return types 149 | 150 | 151 | def Python_Type_List_to_OSC_Type(types_): 152 | output = [] 153 | for type_ in types_: 154 | if type_ == int: 155 | output.append("i") 156 | elif type_ == float: 157 | output.append("f") 158 | elif type_ == bool: 159 | output.append("T") 160 | elif type_ == str: 161 | output.append("s") 162 | else: 163 | raise Exception(f"Cannot convert {type_} to OSC type!") 164 | 165 | return " ".join(output) 166 | 167 | 168 | if __name__ == "__main__": 169 | root = OSCQueryNode("/", description="root node") 170 | root.add_child_node(OSCQueryNode("/test/node/one")) 171 | root.add_child_node(OSCQueryNode("/test/node/two")) 172 | root.add_child_node(OSCQueryNode("/test/othernode/one")) 173 | root.add_child_node(OSCQueryNode("/test/othernode/three")) 174 | 175 | #print(root) 176 | 177 | for child in root: 178 | print(child) -------------------------------------------------------------------------------- /src/tinyoscquery/utility.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | def get_open_tcp_port(): 4 | ''' 5 | Returns a valid, open, TCP port. 6 | 7 | Returns: 8 | port (int): A TCP port that is able to be bound to 9 | ''' 10 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 11 | s.bind(("", 0)) 12 | port = s.getsockname()[1] 13 | s.close() 14 | return port 15 | 16 | def get_open_udp_port(): 17 | ''' 18 | Returns a valid, open, UDP port. 19 | 20 | Returns: 21 | port (int): A UDP port that is able to be bound to 22 | ''' 23 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 24 | s.bind(("", 0)) 25 | port = s.getsockname()[1] 26 | s.close() 27 | return port 28 | 29 | def check_if_tcp_port_open(port: int): 30 | ''' 31 | Checks if a TCP port is open. 32 | 33 | Args: 34 | port (int): The port to check 35 | 36 | Returns: 37 | open (bool): True if the port is open, False if it is not 38 | ''' 39 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 40 | try: 41 | s.bind(("", port)) 42 | s.close() 43 | return True 44 | except OSError: 45 | return False 46 | 47 | def check_if_udp_port_open(port: int): 48 | ''' 49 | Checks if a UDP port is open. 50 | 51 | Args: 52 | port (int): The port to check 53 | 54 | Returns: 55 | open (bool): True if the port is open, False if it is not 56 | ''' 57 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 58 | try: 59 | s.bind(("", port)) 60 | s.close() 61 | return True 62 | except OSError: 63 | return False -------------------------------------------------------------------------------- /src/voicemeeter/__init__.py: -------------------------------------------------------------------------------- 1 | import subprocess as sp 2 | import time 3 | 4 | from .remote import connect as remote 5 | from .driver import vm_subpath 6 | from . import kinds 7 | 8 | def launch(kind_id, delay=1): 9 | """ Starts Voicemeeter. """ 10 | kind = kinds.get(kind_id) 11 | sp.Popen([vm_subpath(kind.executable)]) 12 | time.sleep(delay) 13 | 14 | __ALL__ = ['launch', 'remote'] -------------------------------------------------------------------------------- /src/voicemeeter/driver.py: -------------------------------------------------------------------------------- 1 | from os import path 2 | import sys 3 | import platform 4 | import ctypes 5 | 6 | from .errors import VMRError 7 | 8 | bits = 64 if sys.maxsize > 2**32 else 32 9 | os = platform.system() 10 | 11 | if os != 'Windows' or bits != 64: 12 | raise VMRError('The vmr package only supports Windows 64-bit') 13 | 14 | 15 | DLL_NAME = 'VoicemeeterRemote64.dll' 16 | 17 | vm_base = path.join(path.expandvars('%ProgramFiles(x86)%'), 'VB', 'Voicemeeter') 18 | 19 | def vm_subpath(*fragments): 20 | """ Returns a path based from Voicemeeter's install directory. """ 21 | return path.join(vm_base, *fragments) 22 | 23 | dll_path = vm_subpath(DLL_NAME) 24 | 25 | if not path.exists(dll_path): 26 | raise VMRError(f'Could not find {DLL_NAME}') 27 | 28 | dll = ctypes.cdll.LoadLibrary(dll_path) -------------------------------------------------------------------------------- /src/voicemeeter/errors.py: -------------------------------------------------------------------------------- 1 | class VMRError(Exception): 2 | """ Base error class for Voicemeeter Remote. """ 3 | pass 4 | 5 | class VMRDriverError(VMRError): 6 | """ Raised when a low-level C API function returns an unexpected value. """ 7 | def __init__(self, fn_name, retval): 8 | self.function = fn_name 9 | self.retval = retval 10 | 11 | super().__init__(f'VMR#{fn_name}() returned {retval}') -------------------------------------------------------------------------------- /src/voicemeeter/input.py: -------------------------------------------------------------------------------- 1 | from .errors import VMRError 2 | from .strip import VMElement, bool_prop, str_prop, float_prop 3 | from . import kinds 4 | 5 | class InputStrip(VMElement): 6 | """ Base class for input strips. """ 7 | @classmethod 8 | def make(cls, is_physical, remote, index, **kwargs): 9 | """ 10 | Factory function for input strips. 11 | 12 | Returns a physical/virtual strip for the remote's kind. 13 | """ 14 | PhysStrip, VirtStrip = _strip_pairs[remote.kind.id] 15 | IS_cls = PhysStrip if is_physical else VirtStrip 16 | return IS_cls(remote, index, **kwargs) 17 | 18 | @property 19 | def identifier(self): 20 | return f'Strip[{self.index}]' 21 | 22 | solo = bool_prop('Solo') 23 | mute = bool_prop('Mute') 24 | 25 | gain = float_prop('Gain', range=(-60,12)) 26 | comp = float_prop('Comp', range=(0,10)) 27 | gate = float_prop('Gate', range=(0,10)) 28 | limit = float_prop('Limit', range=(-40,12)) 29 | 30 | eqgain1 = float_prop('EQGain1', range=(-12,12)) 31 | eqgain2 = float_prop('EQGain2', range=(-12,12)) 32 | eqgain3 = float_prop('EQGain3', range=(-12,12)) 33 | 34 | label = str_prop('Label') 35 | device = str_prop('device.name') 36 | sr = str_prop('device.sr') 37 | 38 | class PhysicalInputStrip(InputStrip): 39 | mono = bool_prop('Mono') 40 | 41 | class VirtualInputStrip(InputStrip): 42 | mono = bool_prop('MC') 43 | 44 | 45 | def _make_strip_mixin(kind): 46 | """ Creates a mixin with the kind's strip layout set as class variables. """ 47 | num_A, num_B = kind.layout 48 | return type(f'StripMixin{kind.name}', (), { 49 | **{f'A{i}': bool_prop(f'A{i}') for i in range(1, num_A+1)}, 50 | **{f'B{i}': bool_prop(f'B{i}') for i in range(1, num_B+1)} 51 | }) 52 | 53 | _strip_mixins = {kind.id: _make_strip_mixin(kind) for kind in kinds.all} 54 | 55 | def _make_strip_pair(kind): 56 | """ Creates a PhysicalInputStrip and a VirtualInputStrip of a kind. """ 57 | StripMixin = _strip_mixins[kind.id] 58 | PhysStrip = type(f'PhysicalInputStrip{kind.name}', (PhysicalInputStrip, StripMixin), {}) 59 | VirtStrip = type(f'VirtualInputStrip{kind.name}', (VirtualInputStrip, StripMixin), {}) 60 | return (PhysStrip, VirtStrip) 61 | 62 | _strip_pairs = {kind.id: _make_strip_pair(kind) for kind in kinds.all} 63 | -------------------------------------------------------------------------------- /src/voicemeeter/kinds.py: -------------------------------------------------------------------------------- 1 | from collections import namedtuple 2 | from .errors import VMRError 3 | 4 | """ 5 | Represents a major version of Voicemeeter and describes 6 | its strip layout. 7 | """ 8 | VMKind = namedtuple('VMKind', ['id', 'name', 'layout', 'executable']) 9 | 10 | _kind_map = { 11 | 'basic': VMKind('basic', 'Basic', (2,1), 'voicemeeter.exe'), 12 | 'banana': VMKind('banana', 'Banana', (3,2), 'voicemeeterpro.exe'), 13 | 'potato': VMKind('potato', 'Potato', (5,3), 'voicemeeter8.exe') 14 | } 15 | 16 | def get(kind_id): 17 | try: 18 | return _kind_map[kind_id] 19 | except KeyError: 20 | raise VMRError(f'Invalid Voicemeeter kind: {kind_id}') 21 | 22 | all = list(_kind_map.values()) -------------------------------------------------------------------------------- /src/voicemeeter/output.py: -------------------------------------------------------------------------------- 1 | # param_name => is_numeric 2 | from .errors import VMRError 3 | from .strip import VMElement, bool_prop, str_prop, float_prop 4 | 5 | class OutputBus(VMElement): 6 | """ Base class for output busses. """ 7 | @classmethod 8 | def make(cls, is_physical, *args, **kwargs): 9 | """ 10 | Factory function for output busses. 11 | 12 | Returns a physical/virtual strip for the remote's kind 13 | """ 14 | OB_cls = PhysicalOutputBus if is_physical else VirtualOutputBus 15 | return OB_cls(*args, **kwargs) 16 | 17 | @property 18 | def identifier(self): 19 | return f'Bus[{self.index}]' 20 | 21 | mute = bool_prop('Mute') 22 | gain = float_prop('Gain', range=(-60,12)) 23 | 24 | class PhysicalOutputBus(OutputBus): 25 | pass 26 | 27 | class VirtualOutputBus(OutputBus): 28 | pass -------------------------------------------------------------------------------- /src/voicemeeter/profiles.py: -------------------------------------------------------------------------------- 1 | import os 2 | import toml 3 | from . import kinds 4 | from .errors import VMRError 5 | from .util import project_path, merge_dicts 6 | 7 | profiles = {} 8 | 9 | def _make_blank_profile(kind): 10 | num_A, num_B = kind.layout 11 | input_strip_config = { 12 | 'gain': 0.0, 13 | 'solo': False, 14 | 'mute': False, 15 | 'mono': False, 16 | **{f'A{i}': False for i in range(1, num_A+1)}, 17 | **{f'B{i}': False for i in range(1, num_B+1)} 18 | } 19 | output_strip_config = { 20 | 'gain': 0.0, 21 | 'mute': False 22 | } 23 | return { 24 | **{f'in-{i}': input_strip_config for i in range(num_A+num_B)}, 25 | **{f'out-{i}': output_strip_config for i in range(num_A+num_B)} 26 | } 27 | 28 | def _make_base_profile(kind): 29 | num_A, num_B = kind.layout 30 | blank = _make_blank_profile(kind) 31 | overrides = { 32 | **{f'in-{i}': dict(B1=True) for i in range(num_A)}, 33 | **{f'in-{i}': dict(A1=True) for i in range(num_A, num_A+num_B)} 34 | } 35 | abc = merge_dicts(blank, overrides) 36 | return abc 37 | 38 | for kind in kinds.all: 39 | profiles[kind.id] = { 40 | 'blank': _make_blank_profile(kind), 41 | 'base': _make_base_profile(kind) 42 | } 43 | 44 | # Load profiles from config files in profiles//.toml 45 | if os.path.exists(project_path('profiles')): 46 | for kind in kinds.all: 47 | profile_folder = project_path('profiles', kind.id) 48 | if os.path.exists(profile_folder): 49 | filenames = [f for f in os.listdir(profile_folder) if f.endswith('.toml')] 50 | configs = {} 51 | for filename in filenames: 52 | name = filename[:-5] # strip of .toml extension 53 | try: 54 | configs[name] = toml.load(project_path('profiles', kind.id, filename)) 55 | except toml.TomlDecodeError: 56 | print(f'Invalid TOML profile: {kind.id}/{filename}') 57 | 58 | for name, cfg in configs.items(): 59 | print(f'Loaded profile {kind.id}/{name}') 60 | profiles[kind.id][name] = cfg -------------------------------------------------------------------------------- /src/voicemeeter/remote.py: -------------------------------------------------------------------------------- 1 | import ctypes as ct 2 | import time 3 | import abc 4 | 5 | from .driver import dll 6 | from .errors import VMRError, VMRDriverError 7 | from .input import InputStrip 8 | from .output import OutputBus 9 | from . import kinds 10 | from . import profiles 11 | from .util import merge_dicts 12 | 13 | loggedIn = False 14 | 15 | 16 | class VMRemote(abc.ABC): 17 | """ Wrapper around Voicemeeter Remote's C API. """ 18 | 19 | def __init__(self, delay=.015): 20 | self.delay = delay 21 | self.cache = {} 22 | 23 | def _call(self, fn, *args, check=True, expected=(0,)): 24 | """ 25 | Runs a C API function. 26 | 27 | Raises an exception when check is True and the 28 | function's return value is not 0 (OK). 29 | """ 30 | fn_name = 'VBVMR_' + fn 31 | retval = getattr(dll, fn_name)(*args) 32 | if check and retval not in expected: 33 | raise VMRDriverError(fn_name, retval) 34 | time.sleep(self.delay) 35 | return retval 36 | 37 | def _login(self): 38 | global loggedIn 39 | if (loggedIn == False): 40 | self._call('Login') 41 | loggedIn = True 42 | 43 | def _logout(self): 44 | global loggedIn 45 | if (loggedIn == True): 46 | self._call('Logout') 47 | loggedIn = False 48 | 49 | def login(self): 50 | global loggedIn 51 | if (loggedIn == False): 52 | self._call('Login') 53 | loggedIn = True 54 | 55 | def logout(self): 56 | self._logout() 57 | 58 | @property 59 | def type(self): 60 | """ Returns the type of Voicemeeter installation (basic, banana, potato). """ 61 | buf = ct.c_long() 62 | self._call('GetVoicemeeterType', ct.byref(buf)) 63 | val = buf.value 64 | if val == 1: 65 | return 'basic' 66 | elif val == 2: 67 | return 'banana' 68 | elif val == 3: 69 | return 'potato' 70 | else: 71 | raise VMRError(f'Unexpected Voicemeeter type: {val}') 72 | 73 | @property 74 | def version(self): 75 | """ Returns Voicemeeter's version as a tuple (v1, v2, v3, v4) """ 76 | buf = ct.c_long() 77 | self._call('GetVoicemeeterVersion', ct.byref(buf)) 78 | v1 = (buf.value & 0xFF000000) >> 24 79 | v2 = (buf.value & 0x00FF0000) >> 16 80 | v3 = (buf.value & 0x0000FF00) >> 8 81 | v4 = (buf.value & 0x000000FF) 82 | return (v1, v2, v3, v4) 83 | 84 | @property 85 | def dirty(self): 86 | """ True iff UI parameters have been updated. """ 87 | val = self._call('IsParametersDirty', expected=(0, 1)) 88 | return (val == 1) 89 | 90 | def get(self, param, string=False): 91 | """ Retrieves a parameter. """ 92 | param = param.encode('ascii') 93 | if not self.dirty: 94 | if param in self.cache: 95 | pass 96 | # return self.cache[param] 97 | 98 | if string: 99 | buf = (ct.c_wchar * 512)() 100 | self._call('GetParameterStringW', param, ct.byref(buf)) 101 | else: 102 | buf = ct.c_float() 103 | self._call('GetParameterFloat', param, ct.byref(buf)) 104 | val = buf.value 105 | self.cache[param] = val 106 | return val 107 | 108 | def set(self, param, val): 109 | """ Updates a parameter. """ 110 | param = param.encode('ascii') 111 | if isinstance(val, str): 112 | if len(val) >= 512: 113 | raise VMRError('String is too long') 114 | self._call('SetParameterStringW', param, ct.c_wchar_p(val)) 115 | else: 116 | self._call('SetParameterFloat', param, ct.c_float(float(val))) 117 | 118 | def show(self): 119 | """ Shows Voicemeeter if it's hidden. """ 120 | self.set('Command.Show', 1) 121 | 122 | def shutdown(self): 123 | """ Closes Voicemeeter. """ 124 | self.set('Command.Shutdown', 1) 125 | 126 | def restart(self): 127 | """ Restarts Voicemeeter's audio engine. """ 128 | self.set('Command.Restart', 1) 129 | 130 | def load(self, preset): 131 | """ Loads a preset saved by Voicemeeter. """ 132 | self.set('Command.Load', preset) 133 | 134 | def apply(self, mapping): 135 | """ Sets all parameters of a dict. """ 136 | for key, submapping in mapping.items(): 137 | strip, index = key.split('-') 138 | index = int(index) 139 | if strip in ('in', 'input'): 140 | target = self.inputs[index] 141 | elif strip in ('out', 'output'): 142 | target = self.outputs[index] 143 | else: 144 | raise ValueError(strip) 145 | target.apply(submapping) 146 | 147 | def apply_profile(self, name): 148 | try: 149 | profile = self.profiles[name] 150 | if 'extends' in profile: 151 | base = self.profiles[profile['extends']] 152 | profile = merge_dicts(base, profile) 153 | del profile['extends'] 154 | self.apply(profile) 155 | except KeyError: 156 | raise VMRError(f'Unknown profile: {self.kind.id}/{name}') 157 | 158 | def reset(self): 159 | self.apply_profile('base') 160 | 161 | def __enter__(self): 162 | self._login() 163 | return self 164 | 165 | def __exit__(self, type, value, traceback): 166 | self.logout() 167 | 168 | 169 | def _make_remote(kind): 170 | """ 171 | Creates a new remote class and sets its number of inputs 172 | and outputs for a VM kind. 173 | 174 | The returned class will subclass VMRemote. 175 | """ 176 | 177 | def init(self, *args, **kwargs): 178 | VMRemote.__init__(self, *args, **kwargs) 179 | self.kind = kind 180 | self.num_A, self.num_B = kind.layout 181 | self.inputs = tuple(InputStrip.make((i < self.num_A), self, i) for i in range(self.num_A + self.num_B)) 182 | self.outputs = tuple(OutputBus.make((i < self.num_B), self, i) for i in range(self.num_A + self.num_B)) 183 | 184 | def get_profiles(self): 185 | return profiles.profiles[kind.id] 186 | 187 | return type(f'VMRemote{kind.name}', (VMRemote,), { 188 | '__init__': init, 189 | 'profiles': property(get_profiles) 190 | }) 191 | 192 | 193 | _remotes = {kind.id: _make_remote(kind) for kind in kinds.all} 194 | 195 | 196 | def connect(kind_id, delay=None): 197 | if delay is None: 198 | delay = .015 199 | """ Connect to Voicemeeter and sets its strip layout. """ 200 | try: 201 | cls = _remotes[kind_id] 202 | return cls(delay=delay) 203 | except KeyError as err: 204 | raise VMRError(f'Invalid Voicemeeter kind: {kind_id}') -------------------------------------------------------------------------------- /src/voicemeeter/strip.py: -------------------------------------------------------------------------------- 1 | import abc 2 | from .errors import VMRError 3 | 4 | class VMElement(abc.ABC): 5 | """ Base class for InputStrip and OutputBus. """ 6 | def __init__(self, remote, index): 7 | self._remote = remote 8 | self.index = index 9 | 10 | def get(self, param, **kwargs): 11 | """ Returns the param value of the current strip. """ 12 | return self._remote.get(f'{self.identifier}.{param}', **kwargs) 13 | def set(self, param, val, **kwargs): 14 | """ Sets the param value of the current strip. """ 15 | self._remote.set(f'{self.identifier}.{param}', val, **kwargs) 16 | 17 | @abc.abstractmethod 18 | def identifier(self): 19 | pass 20 | 21 | def apply(self, mapping): 22 | """ Sets all parameters of a dict for the strip. """ 23 | for key, val in mapping.items(): 24 | if not hasattr(self, key): 25 | raise VMRError(f'Invalid {self.identifier} attribute: {key}') 26 | setattr(self, key, val) 27 | 28 | 29 | def bool_prop(param): 30 | """ A boolean VM parameter. """ 31 | def getter(self): 32 | return (self.get(param) == 1) 33 | def setter(self, val): 34 | return self.set(param, 1 if val else 0) 35 | return property(getter, setter) 36 | 37 | def str_prop(param): 38 | """ A string VM parameter. """ 39 | def getter(self): 40 | return self.get(param, string=True) 41 | def setter(self, val): 42 | return self.set(param, val) 43 | return property(getter, setter) 44 | 45 | def float_prop(param, range=None, normalize=False): 46 | """ A floating point VM parameter. """ 47 | def getter(self): 48 | val = self.get(param) 49 | if range: 50 | lo, hi = range 51 | if normalize: 52 | val = (val-lo)/(hi-lo) 53 | return val 54 | def setter(self, val): 55 | if range: 56 | lo, hi = range 57 | if normalize: 58 | val = val*(hi-lo)+lo 59 | return self.set(param, val) 60 | return property(getter, setter) -------------------------------------------------------------------------------- /src/voicemeeter/util.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | PROJECT_DIR = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) 4 | 5 | def project_path(*parts): 6 | return os.path.join(PROJECT_DIR, *parts) 7 | 8 | def merge_dicts(*srcs, dest={}): 9 | target = dest 10 | for src in srcs: 11 | for key, val in src.items(): 12 | if isinstance(val, dict): 13 | node = target.setdefault(key, {}) 14 | merge_dicts(val, dest=node) 15 | else: 16 | target[key] = val 17 | return target --------------------------------------------------------------------------------