Current section
6 Versions
Jump to
Current section
6 Versions
Compare versions
8
files changed
+200
additions
-35
deletions
| @@ -99,12 +99,4 @@ end | |
| 99 99 | Mix.install([{:supercollider, "~> 0.1.0"}]) |
| 100 100 | ``` |
| 101 101 | ## Documentation |
| 102 | - The docs can be found at <https://hexdocs.pm/supercollider>. |
| 103 | - |
| 104 | - If [available in Hex](https://hex.pm/docs/publish) |
| 105 | - |
| 106 | - |
| 107 | - |
| 108 | - Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) |
| 109 | - and published on [HexDocs](https://hexdocs.pm). Once published, the docs can |
| 110 | - be found at <https://hexdocs.pm/supercollider>. |
| \ No newline at end of file | |
| 102 | + The docs can be found at <https://hexdocs.pm/supercollider>. |
| \ No newline at end of file |
| @@ -23,4 +23,4 @@ | |
| 23 23 | {<<"optional">>,false}, |
| 24 24 | {<<"repository">>,<<"hexpm">>}, |
| 25 25 | {<<"requirement">>,<<"~> 0.1.2">>}]]}. |
| 26 | - {<<"version">>,<<"0.1.0">>}. |
| 26 | + {<<"version">>,<<"0.1.1">>}. |
| @@ -45,6 +45,8 @@ defmodule SuperCollider do | |
| 45 45 | - socket: the UDP socket used to communicate with scserver, once the connection is open. |
| 46 46 | - type: the server type being used, accepts :scsynth (default) or :supernova (multicore) |
| 47 47 | |
| 48 | + Note if the hostname is set to `nil` it will try the IP address at `ip`. |
| 49 | + |
| 48 50 | ## Examples |
| 49 51 | Start SuperCollider with defaults |
| 50 52 | ``` |
| @@ -55,6 +57,12 @@ defmodule SuperCollider do | |
| 55 57 | ``` |
| 56 58 | SuperCollider.start(type: :supernova) |
| 57 59 | ``` |
| 60 | + |
| 61 | + This function starts the `SuperCollider.SoundServer` GenServer which will check if SuperCollider has booted on your system. If not, it will currently attempt to start scynth or supernova at the following locations: |
| 62 | + |
| 63 | + - Mac: /Applications/SuperCollider.app/Contents/Resources/ |
| 64 | + - Linux: /usr/local/ |
| 65 | + - Windows: \\Program Files\\SuperCollider\\ |
| 58 66 | """ |
| 59 67 | def start(opts \\ []) do |
| 60 68 | {:ok, pid} = GenServer.start_link(SoundServer, SoundServer.new(opts)) |
| @@ -3,10 +3,21 @@ defmodule SuperCollider.SoundServer do | |
| 3 3 | require Logger |
| 4 4 | |
| 5 5 | @server_type [ |
| 6 | - scsynth: "/Applications/SuperCollider.app/Contents/Resources/scsynth", |
| 7 | - supernova: "/Applications/SuperCollider.app/Contents/Resources/supernova" |
| 6 | + mac: [ |
| 7 | + scsynth: "/Applications/SuperCollider.app/Contents/Resources/scsynth", |
| 8 | + supernova: "/Applications/SuperCollider.app/Contents/Resources/supernova" |
| 9 | + ], |
| 10 | + unix: [ |
| 11 | + scsynth: "/usr/local/scsynth", |
| 12 | + supernova: "/usr/local/supernova" |
| 13 | + ], |
| 14 | + windows: [ |
| 15 | + scsynth: "\\Program Files\\SuperCollider\\sclang.exe", |
| 16 | + supernova: "\\Program Files\\SuperCollider\\supernova.exe" |
| 17 | + ] |
| 8 18 | ] |
| 9 19 | |
| 20 | + |
| 10 21 | @moduledoc """ |
| 11 22 | This module is a: |
| 12 23 | - GenServer which is used to communicate with SuperCollider's scserver or supernova |
| @@ -274,13 +285,18 @@ defmodule SuperCollider.SoundServer do | |
| 274 285 | @doc """ |
| 275 286 | Checks if scsynth is loaded by calling `scsynth_booted?/1`. If not it will attempt to boot it asynchronously using `Task.async/1`. |
| 276 287 | |
| 277 | - TODO: The location of the scysnth binary is currently set in the `@scsynth_binary_location` but this will need to be moved out into a config or using different search strategies for different OSes. |
| 288 | + Currently attempts to start scynth or supernova at the following locations: |
| 278 289 | |
| 290 | + - Mac: /Applications/SuperCollider.app/Contents/Resources/ |
| 291 | + - Linux: /usr/local/ |
| 292 | + - Windows: \\Program Files\\SuperCollider\\ |
| 293 | + |
| 294 | + TODO: The location of the scysnth binary is currently set to the fixed locations above, but this will need to be moved out into a config or using different search strategies for different OSes. |
| 279 295 | """ |
| 280 296 | def maybe_boot_scsynth(soundserver) do |
| 281 297 | Logger.info("#{soundserver.type} - waiting up to 5 seconds to see if already loaded ⏳") |
| 282 298 | |
| 283 | - cmd = @server_type[soundserver.type] |
| 299 | + cmd = @server_type[os_type()][soundserver.type] |
| 284 300 | |
| 285 301 | if !scsynth_booted?(soundserver) do |
| 286 302 | Logger.info("#{soundserver.type} - attempting to start 🏁") |
| @@ -328,4 +344,14 @@ defmodule SuperCollider.SoundServer do | |
| 328 344 | false |
| 329 345 | end |
| 330 346 | end |
| 347 | + |
| 348 | + # Returns of the OS type as :windows, :mac or :unix |
| 349 | + defp os_type do |
| 350 | + case :os.type() do |
| 351 | + {:win32, _} -> :windows |
| 352 | + {:unix, :darwin} -> :mac |
| 353 | + {:unix, _} -> :unix |
| 354 | + end |
| 355 | + end |
| 356 | + |
| 331 357 | end |
| @@ -44,7 +44,7 @@ defmodule SuperCollider.SoundServer.Command do | |
| 44 44 | """ |
| 45 45 | |
| 46 46 | def send_to_sc(soundserver, osc_message) do |
| 47 | - :gen_udp.send(soundserver.socket, soundserver.hostname, soundserver.port, osc_message) |
| 47 | + :gen_udp.send(soundserver.socket, soundserver.hostname||soundserver.ip, soundserver.port, osc_message) |
| 48 48 | end |
| 49 49 | |
| 50 50 | @doc """ |
Loading more files…