rtaudio.bmx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. SuperStrict
  2. Rem
  3. bbdoc: MaxMod2.RtAudio
  4. about: This module provides cross platform audio streaming via RtAudio<p>
  5. <h2>RtAudio License</h2>
  6. <table><table width=100%><td>
  7. RtAudio: a set of realtime audio i/o C++ classes<br>
  8. Copyright (c) 2001-2007 Gary P. Scavone<p>
  9. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:<p>
  10. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.<p>
  11. Any person wishing to distribute modifications to the Software is asked to send the modifications to the original developer so that they can be incorporated into the canonical version. This is, however, not a binding provision of this license.<p>
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. <p>
  13. </td></table>
  14. <h2>RtAudio Information</h2>
  15. <table><table width=100%>
  16. <tr><th width=1%>Author</th><td>Gary P. Scavone</td></tr>
  17. <tr><th>Website</th><td>http://www.music.mcgill.ca/~gary/rtaudio/</td></tr>
  18. </table>
  19. End Rem
  20. Module MaxMod2.RtAudio
  21. ModuleInfo "MaxMod2: RtAudio interface"
  22. ModuleInfo "Author: REDi - Cliff Harman"
  23. ModuleInfo "CC_OPTS: -fexceptions"
  24. ?Win32
  25. Import "-ldsound"
  26. Import "-lole32"
  27. ?Linux
  28. Import "-lasound"
  29. Import "-lpthread"
  30. Import "-lpulse-simple"
  31. 'Import "-lpulse"
  32. ?MacOS
  33. Import "-framework CoreAudio"
  34. Import "-framework AudioUnit"
  35. Import "-framework AudioToolbox"
  36. Import "-lpthread"
  37. ?
  38. Import MaxMod2.MaxMod2
  39. Import "*.h"
  40. Import "rtaudiodriver.cpp"
  41. Import "RtAudioOS.cpp"
  42. Extern
  43. Function CreateAudioDriver_RtAudio:IMaxModAudioDriver(api:Int, showWarnings:Int)
  44. Function CloseAudioDriver_RtAudio(Driver:IMaxModAudioDriver)
  45. 'ron: added functionality to disable warnings
  46. Function RtAudio_showWarnings(Driver:IMaxModAudioDriver, bool:Int)
  47. End Extern
  48. Type TMaxModRtAudioDriver Extends TMaxModDriver
  49. 'ron: we store the active one in TMaxModDriver
  50. ' Global Active:TMaxModRtAudioDriver
  51. 'ron: show the warnings of rtAudio ?
  52. Global optShowWarnings:Int = True
  53. Method Delete()
  54. CloseAudioDriver_RtAudio(_driver)
  55. EndMethod
  56. 'register on create
  57. Method New()
  58. Self.registerAPIs()
  59. End Method
  60. Function CreateSpecific:TMaxModDriver( name:String, api:String)
  61. ' if Active <> null then CloseAudioDriver_RtAudio( Active._driver)
  62. Active = New TMaxModRtAudioDriver
  63. Active._driver = CreateAudioDriver_RtAudio( Active.GetAPIid(api), optShowWarnings)
  64. Active._name = name
  65. Return Active
  66. End Function
  67. Method registerAPIs()
  68. Self.AddAPI(0, "AUTOMATIC") '= "UNSPECIFIED"
  69. ?Linux
  70. Self.AddAPI(1, "LINUX_ALSA")
  71. Self.AddAPI(2, "LINUX_PULSE")
  72. Self.AddAPI(3, "LINUX_OSS")
  73. Self.AddAPI(4, "UNIX_JACK")
  74. ?MacOS
  75. Self.AddAPI(5, "MACOSX_CORE")
  76. ?Win32
  77. Self.AddAPI(6, "WINDOWS_ASIO")
  78. Self.AddAPI(7, "WINDOWS_DS")
  79. ?
  80. End Method
  81. Function Create:TMaxModDriver( name$)
  82. If Active Return Active
  83. Active = New TMaxModRtAudioDriver
  84. Active._driver = CreateAudioDriver_RtAudio( 0, optShowWarnings )
  85. Active._name = name
  86. Return Active
  87. End Function
  88. Function showWarnings(bool:Int)
  89. optShowWarnings = bool
  90. If Active
  91. RtAudio_showWarnings(Active._driver, optShowWarnings)
  92. EndIf
  93. End Function
  94. 'registers audio driver (with custom api)
  95. Function Init(api:String="AUTOMATIC")
  96. TMaxModRtAudioDriver.CreateSpecific("MaxMod RtAudio", api)
  97. TMaxModStreamDriver.AddDriver(TMaxModRtAudioDriver.Active,"MaxMod RtAudio")
  98. End Function
  99. End Type
  100. Rem
  101. ?Linux
  102. 'default to Linux pulse on linux
  103. TMaxModRtAudioDriver.CreateSpecific("MaxMod RtAudio", "LINUX_PULSE")
  104. ?not Linux
  105. TMaxModRtAudioDriver.CreateSpecific("MaxMod RtAudio", "AUTOMATIC")
  106. ?
  107. TMaxModStreamDriver.AddDriver(TMaxModRtAudioDriver.Active,"MaxMod RtAudio")
  108. endrem