mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-25 13:38:34 -06:00
* Add sonification module * WIP: Extract planet positions in own thread * WIP Extract camera position and angle * Extract distance to camera and fix angle * WIP: Extract focus node * Optimize and clean up * Fix signed angle for surround sound * WIP add solar system view sonification * Extract time Extract the speed of time in OpenSpace and send it to supercollider. Needed to scale the sonification time in sync with OpenSpace * Extract moon angles Extract the angle from the planet to the major moons. Used in sonification to position the moons in surround. * Add easy change of angles Easier to switch what angle is calculated and sent to the sonification. Preperation for test in Dome * Fix shutdown error and nullptr error Add deinitialize for sonification module. Make sure pointers are initialized to nullptrs at start. Check in sonification main in the start if the scene is initialized * Add properties to contol sonification * Add property to turn on/off sonification for each planet * Change so the data only send for those planets that are enabled with the property * WIP: Improve GUI for sonification control * Add GUI for every sonification parameter per planet * However, only for Earth and Mars so far * Make data send more often and not just when the planet is enabled * Add sonification GUI for Mercury and Venus * GUI for each parameter for Marcury and Venus * Send a shutdown message to SuperCollider during deinitialization * Group properties together * Gather the planets properties under a planets property owner * Prepare to expand GUI * Name changes * Add Solar view in GUI * Add GUI that controls the solar sonification * Remove the all enabled slot in the settings arrays * No longer sends the all enabled slot in teh settings arrays * WIP Compare view * Add compare view in GUI. Allows to compare two planets sonification. * Finish compare view * Add connection to sonification for compare view * Improve responsiveness of GUI * Expand GUI with the outer planets * Add GUI for the outer planets * Increase array sizes to compe with all the planets * Add functionality for the outer planets GUI * Add temperature option in GUI * Fix so that compare cannot compare to itself * Scale selected planets in compare view * Fix reset of compare view * Add Rings sonification to GUI * Fix solar sonification GUI * Bind onChange function for the outer planets in the solar GUI * Add comment about where in the settings array the setting for rings are * Add master buttuns in GUI * Add button to turn on/off all the planets * Add button to turn on/off everything, solar when sun is in focus and planetary otherwise. * Add function to easier turn on/off all the parameters of solar and planetary * Only master start sonification module * Add check that only the master start the sonification thread * Clean up a few lines in the angle calculation * Optimize the sending of time * Time is not sent with every message but only when it changes instead * Add GUI for choosing what parts to compare * More GUI in compare view to control which sonification to compare * Fix deinitialize turn off sounds * Make sure the auto (enable all) now also work with the new compare GUI * Fix socket problem and code clean up * Only use one socket to send information to supercollider * General code clean up * Remove sending of focus node since supercollider does not use it * Adjust to new master * Fix oscpack linker issues * Update to new master * Add start of SonificationEngine * Move osc code into SonificationEngine * Add function for the planetary settings * Add function to access SonificationEngine via the module * Add base sonification class * Start seperating into different sonification classes * Add PlanetarySonification to the internal list * Move osc to its own module * Seperate planet sonifications into seperate sonification classes * Make time sonification its own class * Some clean up * Update to new cmake version * Add proper module dependency for the sonification module * Fix thread issue * Temporary fix with a sleep, works for now * Fix log messages issue * Add enabled property for the sonification module * Some clean up * More clean up * More clean up * Make it possible to send in node position directly for helper function * Add stop function for sonifications * Make possible to specify sonification destination ip and port in cfg file * Use Parameters struct for the sonification module dictionary * Make sonification module a singleton * Minor code style fix * Use module engine module function for singleton pattern instead * Add angle calculations for the surround modes * Use codegen map function for surround mode enum * Improve data storage and sending for planet sonificaitons * Add focus sonification * Fix elevation angle calculation for circular surround mode * Add Lua function to add entries for the PlanetsSonification * Add sonification profile * Add lua library file for planets sonification * Fix gui osc messages sending * Update to latest master * Rename planets sonificaitons to reflect they only work for planets * Add generic nodes sonification * Clean up Time sonification * plus a little in the nodes sonification * Add current time information to the time sonification * Add precision propertysubowner to structure Gui and make it flexible * Some general clean up * Rename solar sonification to planets overview sonification * Add Camera sonification * Fix some bugs with the camera sonificaiton * Make sure the sonificaiton thread is synced with the main thread * Fix camera and scene bug in sonificaiton * Dont hold up the main thread while sonificaiton thread does its work * Use the current frame time for speed calculaiton instead of average * Fix osc::Blob memory bug * Wait max 30 seconds in the sonification thread for the main thread * Make sure deinitialize of sonificaiton thread does not halt * Add the mode sonification as a proper sonification * Add nodes sonification example with ISS and Tiangong * Some renaming and restructuring * Add more detailed documentation for the sonification math * The util functions for different angles in the sonificaiton/telemetry module * Major clean up and restructuring * Rename module to telemetry to make it more clear that we do not produce the sonifications, we just spit out data used by a sonificaiton software * Add the new moon of Neptune to sonification and add sonification files * And add the test osc supercollider file * Add the OpenSpace header to the supercollider example file * Apply suggestions from code review Co-authored-by: Alexander Bock <alexander.bock@liu.se> * Adjust suggestions to fix errors * Address more PR comments * Address more PR comments * More PR comments * More PR comments * More PR comments * Even more PR comments * Update to latest master * More PR comments * Add OSC as a submodule * NOTE that due to path issues this commit will not build with the osc module, you will need to change the paths inside two osc files for it to build. Will fix very soon * Fix issue with oscpack not setting correct include directory * Address PR comments * Address PR comments * Update the SuperCollider files --------- Co-authored-by: Alexander Bock <alexander.bock@liu.se> Co-authored-by: Ivar Gorenko <ivago071@student.liu.se>
439 lines
15 KiB
Plaintext
439 lines
15 KiB
Plaintext
/*****************************************************************************************
|
|
* *
|
|
* OpenSpace *
|
|
* *
|
|
* Copyright (c) 2014-2025 *
|
|
* *
|
|
* 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: *
|
|
* *
|
|
* The above copyright notice and this permission notice shall be included in all copies *
|
|
* or substantial portions of the Software. *
|
|
* *
|
|
* 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. *
|
|
****************************************************************************************/
|
|
|
|
Platform.userExtensionDir
|
|
NetAddr.langPort;
|
|
NetAddr.localAddr;
|
|
|
|
/*****************************************************************************************
|
|
* This is a SuperCollider file that needs to be run in the SuperCollider application *
|
|
* that can be downloaded here: https://supercollider.github.io/ *
|
|
* *
|
|
* This is an example file that shows all the messages that the Telemetry module in *
|
|
* OpenSpace can send over Open Sound Control (OSC). SuperCollider can then listen to *
|
|
* these OSC messages and create sounds based on their content (a sonification). This *
|
|
* example only listens to the messages and displays their content in the log to the *
|
|
* right in the SuperCollider application. For a more extensive example that shows how *
|
|
* to create sounds in SuperCollider based on the data from OpenSpace, see the *
|
|
* planets-sonification.scd file located in data\assets\modules\telemetry\sonification. *
|
|
* *
|
|
* To run a SuperCollider file, click any line within the parentheses below, such as the *
|
|
* marked line. When you have selected a line, press the CTRL and ENTER keys on your *
|
|
* keyboard at the same time, and SuperCollider will run the code. You will see a *
|
|
* message appear in the log to the right, the message should be: *
|
|
* "-> OSCdef(Neptune, /Neptune, nil, nil, nil)". At this point, SuperCollider is ready *
|
|
* to receive messages from OpenSpace. For a guide on how to enable and use the *
|
|
* Telemetry module inside OpenSpace, see this documentation page: *
|
|
* https://docs.openspaceproject.com/latest/creating-data-assets/modules/telemetry/ *
|
|
* index.html *
|
|
****************************************************************************************/
|
|
|
|
(
|
|
|
|
// To run this example, click this line and press CTRL + ENTER on the keyboard
|
|
// When finished, press CTRL + . on you keyboard simultaneously to stop the sonification
|
|
|
|
// Camera sonification
|
|
OSCdef.new(
|
|
\Camera,
|
|
{
|
|
arg msg;
|
|
|
|
// msg[0] = OSC Label.
|
|
// msg[1] = The x position of the camera in the world.
|
|
// msg[2] = The y position of the camera in the world.
|
|
// msg[3] = The z position of the camera in the world.
|
|
// msg[4] = The w component of the quaternion rotation of the camera.
|
|
// msg[5] = The x component of the quaternion rotation of the camera.
|
|
// msg[6] = The y component of the quaternion rotation of the camera.
|
|
// msg[7] = The z component of the quaternion rotation of the camera.
|
|
// msg[8] = The movement speed of the camera, in the distance unit per second
|
|
// specified by the next item.
|
|
// msg[9] = The distance unit for the movement speed of the camera, as a string in
|
|
// singular form with the first letter capitalized. For example,
|
|
// "Kilometer".
|
|
//
|
|
// Note that the first seven items describe the position and orientation of the
|
|
// camera. The first three items specify the x, y, and z positions of the camera
|
|
// in the world, in relation to the solar system barycenter. The next four items
|
|
// are the quaternion rotation of the camera in the order of w, x, y, and z.
|
|
|
|
("Camera: " + msg).postln;
|
|
},
|
|
'/Camera'
|
|
);
|
|
|
|
// Focus sonification
|
|
OSCdef.new(
|
|
\Focus,
|
|
{
|
|
arg msg;
|
|
|
|
// msg[0] = OSC Label.
|
|
// msg[1] = The identifier of the new focus in OpenSpace, as a string.
|
|
|
|
("Focus: " + msg).postln;
|
|
},
|
|
'/Focus'
|
|
);
|
|
|
|
// Surround mode sonification
|
|
OSCdef.new(
|
|
\Mode,
|
|
{
|
|
arg msg;
|
|
|
|
// msg[0] = OSC Label.
|
|
// msg[1] = The first item is an integer value that specifies what method was
|
|
// used to calculate the angles. If the value is 0, then the method
|
|
// used was the Horizontal angle calculation mode. In the case where
|
|
// the value is 1, then the Circular angle calculation mode was used.
|
|
// msg[2] = The second value is an integer value of either 0 or 1 that
|
|
// determines if the additional elevation angle is used or not. If the
|
|
// value is 1, the additional elevation angle is calculated. Otherwise,
|
|
// if 0, the elevation angle is always set to 0.0.
|
|
|
|
("Mode: " + msg).postln;
|
|
},
|
|
'/Mode'
|
|
);
|
|
|
|
// Time sonification
|
|
OSCdef.new(
|
|
\Time,
|
|
{
|
|
arg msg;
|
|
|
|
// msg[0] = OSC Label.
|
|
// msg[1] = The speed of the simulation time, specified in the selected time unit
|
|
// in the simulation, per real-life second. For example, 10 simulated
|
|
// seconds per real-life second means that the simulation goes 10 times
|
|
// faster than real-life.
|
|
// msg[2] = The selected time unit for the speed of simulation time, as a string
|
|
// in singular form with the first letter capitalized. For example,
|
|
// "Day".
|
|
// msg[3] = The current simulation time in OpenSpace specified in J2000 seconds,
|
|
// that is, the number of seconds past the J2000 epoch
|
|
// (i.e. January 1, 2000 12:00:00 TT).
|
|
|
|
("Time: " + msg).postln;
|
|
},
|
|
'/Time'
|
|
);
|
|
|
|
// Nodes sonification, data map:
|
|
// msg[0] = OSC Label (The identifier for each node).
|
|
// msg[1] = The distance from the camera to the node, in the distance unit specified in
|
|
// the last item.
|
|
// msg[2] = The horizontal angle to the node, in radians, with the current angle
|
|
// calculation mode taken into account. For more information, see
|
|
// https://docs.openspaceproject.com/latest/creating-data-assets/modules/
|
|
// telemetry/angle-information.html.
|
|
// msg[3] = The elevation angle to the node, in radians, with the current angle
|
|
// calculation mode taken into account. Again, see
|
|
// https://docs.openspaceproject.com/latest/creating-data-assets/modules/
|
|
// telemetry/angle-information.html for details.
|
|
// msg[4] = The unit for the distance to the camera, as a string in singular form with
|
|
// the first letter capitalized. For example, "Meter".
|
|
|
|
// ISS node
|
|
OSCdef.new(
|
|
\ISS,
|
|
{
|
|
arg msg;
|
|
|
|
// Follow the nodes sonification data map above
|
|
|
|
("ISS: " + msg).postln;
|
|
},
|
|
'/ISS'
|
|
);
|
|
|
|
// Tiangong node
|
|
OSCdef.new(
|
|
\Tiangong,
|
|
{
|
|
arg msg;
|
|
|
|
// Follow the nodes sonification data map above
|
|
|
|
("Tiangong: " + msg).postln;
|
|
},
|
|
'/Tiangong'
|
|
);
|
|
|
|
|
|
// Planet related sonifications:
|
|
// Compare planets
|
|
OSCdef.new(
|
|
\Compare,
|
|
{
|
|
arg msg;
|
|
|
|
// msg[0] = OSC Label.
|
|
// msg[1] = The index of the first planet to be compared. See the list below on
|
|
// how to convert the index to a planet name:
|
|
// 0 -> None selected
|
|
// 1 -> Mercury
|
|
// 2 -> Venus
|
|
// 3 -> Earth
|
|
// 4 -> Mars
|
|
// 5 -> Jupiter
|
|
// 6 -> Saturn
|
|
// 7 -> Uranus
|
|
// 8 -> Neptune
|
|
// msg[2] = The index of the second planet to be compared (will never be the same
|
|
// as the first).
|
|
// msg[3] = List of user interface settings for the comparison, which determines
|
|
// which aspects of the sonification should be turned on or off. A value
|
|
// of 0 means that a setting is turned off, and 1 means that it is turned
|
|
// on. The order of the settings can be seen in the list below:
|
|
// msg[3][0] = Size/day. 1 -> Size/day is turned on.
|
|
// 0 -> Size/day is turned off.
|
|
// msg[3][1] = Gravity
|
|
// msg[3][2] = Temperature
|
|
// msg[3][3] = Atmosphere
|
|
// msg[3][4] = Moons
|
|
// msg[3][5] = Rings
|
|
|
|
("Compare: " + msg).postln;
|
|
|
|
},
|
|
'/Compare'
|
|
);
|
|
|
|
// Planets overview
|
|
OSCdef.new(
|
|
\Overview,
|
|
{
|
|
arg msg;
|
|
|
|
// msg[0] = OSC Label.
|
|
// msg[1] = List of user interface settings for the planets overview. This
|
|
// determines which planets are part of the sonification or not. A value
|
|
// of 0 means that the planet is turned off, and a 1 means that it is
|
|
// turned on. The order of the settings can be seen in the list below:
|
|
// msg[1][0] = Mercury. 1 -> Mercury is turned on.
|
|
// 0 -> Mercury is turned off.
|
|
// msg[1][1] = Venus
|
|
// msg[1][2] = Earth
|
|
// msg[1][3] = Mars
|
|
// msg[1][4] = Jupiter
|
|
// msg[1][5] = Saturn
|
|
// msg[1][6] = Uranus
|
|
// msg[1][7] = Neptune
|
|
|
|
("Overview: " + msg).postln;
|
|
},
|
|
'/Overview'
|
|
);
|
|
|
|
// Planets sonifications, data map:
|
|
// msg[0] = OSC Label (The name of the planet).
|
|
// msg[1] = The distance from the camera to the planet in kilometers.
|
|
// msg[2] = The horizontal angle in radians to the planet, with the current angle
|
|
// calculation mode taken into account. For more information see
|
|
// https://docs.openspaceproject.com/latest/creating-data-assets/modules/
|
|
// telemetry/angle-information.html.
|
|
// msg[3] = The elevation angle in radians to the planet, with the current angle
|
|
// calculation mode taken into account. Again, see
|
|
// https://docs.openspaceproject.com/latest/creating-data-assets/modules/
|
|
// telemetry/angle-information.html for details.
|
|
// msg[4] = List of user interface settings for the planet sonification, which aspects
|
|
// of the sonification should be turned on or off. A value of 0 means that it
|
|
// is turned off, and a 1 means that it is turned on. The order of the
|
|
// settings can be seen in the table below. If the setting does not exist for
|
|
// a planet, the value is always 0.
|
|
// msg[4][0] = Size/day. 1 -> Size/day is turned on.
|
|
// 0 -> Size/day is turned off.
|
|
// msg[4][1] = Gravity
|
|
// msg[4][2] = Temperature
|
|
// msg[4][3] = Atmosphere
|
|
// msg[4][4] = Moons
|
|
// msg[4][5] = Rings
|
|
// msg[5] = (optional) The distance from the camera to the first moon in kilometers.
|
|
// msg[6] = (optional) The horizontal angle in radians to the first moon.
|
|
// msg[7] = (optional) The elevation angle in radians to the first moon.
|
|
// msg[8] = (optional) The distance from the camera to the second moon in kilometers.
|
|
// msg[9] = (optional) The horizontal angle in radians to the second moon.
|
|
// msg[10] = (optional) The elevation angle in radians to the second moon.
|
|
// msg[...] = The data then continues in the same pattern for each of the planet's
|
|
// moons, with three values per moon. The moons are given in order of
|
|
// distance from the planet (closest first, farthest last) as specified in
|
|
// the planets.asset file in the data\assets\modules\telemetry\sonification
|
|
// folder.
|
|
|
|
// Mercury
|
|
OSCdef.new(
|
|
\Mercury,
|
|
{
|
|
arg msg;
|
|
|
|
// Follow the planets sonification data map above
|
|
// Mercury does not have the GUI settings:
|
|
// - Atmosphere
|
|
// - Moons
|
|
// - Rings
|
|
// Mercury have no moon data since it does not have any moon
|
|
|
|
("Mercury: " + msg).postln;
|
|
},
|
|
'/Mercury'
|
|
);
|
|
|
|
// Venus
|
|
OSCdef.new(
|
|
\Venus,
|
|
{
|
|
arg msg;
|
|
|
|
// Follow the planets sonification data map above
|
|
// Venus does not have the GUI settings:
|
|
// - Moons
|
|
// - Rings
|
|
// Venus have no moon data since it does not have any moon
|
|
|
|
("Venus: " + msg).postln;
|
|
},
|
|
'/Venus'
|
|
);
|
|
|
|
// Earth
|
|
OSCdef.new(
|
|
\Earth,
|
|
{
|
|
arg msg;
|
|
|
|
// Follow the planets sonification data map above
|
|
// Earth does not have the GUI settings:
|
|
// - Rings
|
|
// Earth have moon data for one moon:
|
|
// - The Moon
|
|
|
|
("Earth: " + msg).postln;
|
|
},
|
|
'/Earth'
|
|
);
|
|
|
|
// Mars
|
|
OSCdef.new(
|
|
\Mars,
|
|
{
|
|
arg msg;
|
|
|
|
// Follow the planets sonification data map above
|
|
// Mars does not have the GUI settings:
|
|
// - Rings
|
|
// Mars have moon data for 2 moons in the following order:
|
|
// - Phobos
|
|
// - Deimos
|
|
|
|
("Mars: " + msg).postln;
|
|
},
|
|
'/Mars'
|
|
);
|
|
|
|
// Jupiter
|
|
OSCdef.new(
|
|
\Jupiter,
|
|
{
|
|
arg msg;
|
|
|
|
// Follow the planets sonification data map above
|
|
// Jupiter does not have the GUI settings:
|
|
// - Rings (there are rings in real-life, but not in OpenSpace)
|
|
// Jupiter have moon data for 4 moons in the following order:
|
|
// - Io
|
|
// - Europa
|
|
// - Ganymede
|
|
// - Callisto
|
|
|
|
("Jupiter: " + msg).postln;
|
|
},
|
|
'/Jupiter'
|
|
);
|
|
|
|
// Saturn
|
|
OSCdef.new(
|
|
\Saturn,
|
|
{
|
|
arg msg;
|
|
|
|
// Follow the planets sonification data map above
|
|
// Saturn have moon data for 8 moons in the following order:
|
|
// - Dione
|
|
// - Enceladus
|
|
// - Hyperion
|
|
// - Iapetus
|
|
// - Mimas
|
|
// - Rhea
|
|
// - Tethys
|
|
// - Titan
|
|
|
|
("Saturn: " + msg).postln;
|
|
},
|
|
'/Saturn'
|
|
);
|
|
|
|
// Uranus
|
|
OSCdef.new(
|
|
\Uranus,
|
|
{
|
|
arg msg;
|
|
|
|
// Follow the planets sonification data map above
|
|
// Uranus does not have the GUI settings:
|
|
// - Rings (there are rings in real-life, but not in OpenSpace)
|
|
// Uranus have moon data for 5 moons in the following order:
|
|
// - Ariel
|
|
// - Miranda
|
|
// - Oberon
|
|
// - Titania
|
|
// - Umbriel
|
|
|
|
("Uranus: " + msg).postln;
|
|
},
|
|
'/Uranus'
|
|
);
|
|
|
|
// Neptune
|
|
OSCdef.new(
|
|
\Neptune,
|
|
{
|
|
arg msg;
|
|
|
|
// Follow the planets sonification data map above
|
|
// Neptune does not have the GUI settings:
|
|
// - Rings (there are rings in real-life, but not in OpenSpace)
|
|
// Neptune have moon data for 2 moons in the following order:
|
|
// - Triton
|
|
// - Nereid
|
|
|
|
("Neptune: " + msg).postln;
|
|
},
|
|
'/Neptune'
|
|
);
|
|
|
|
)
|