diff --git a/.vscode/settings.json b/.vscode/settings.json index b9f02a0..1d12679 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,5 +18,6 @@ "titleBar.inactiveBackground": "#2d620799", "titleBar.inactiveForeground": "#e7e7e799" }, - "peacock.color": "#2d6207" + "peacock.color": "#2d6207", + "tidalcycles.bootTidalPath": "/home/phillip/Projekte/HTWK/Computermusik/data-composition/configs/BootTidal.hs" } \ No newline at end of file diff --git a/tools/BootTidal.hs b/configs/BootTidal.hs similarity index 71% rename from tools/BootTidal.hs rename to configs/BootTidal.hs index 22489b6..824727d 100644 --- a/tools/BootTidal.hs +++ b/configs/BootTidal.hs @@ -2,9 +2,6 @@ :set -XExtendedDefaultRules :set prompt "" --- Load Data. This currently is pinned to my setup. -:cd /home/phillip/Projekte/HTWK/Computermusik/data-composition/datamodules - import Sound.Tidal.Context import System.IO (hSetEncoding, stdout, utf8) @@ -15,9 +12,29 @@ hSetEncoding stdout utf8 :set -package bytestring :set -package random +-- Load all the Modules i need for data transformation, plotting and other stuff. +import Text.Read +import Data.Maybe +import Graphics.Gnuplot.Simple +import qualified Graphics.Gnuplot.Terminal.QT as QT +import System.Random + + +-- Have Chords available all the time +import Sound.Tidal.Chords + + -- Load Data +:cd /home/phillip/Projekte/HTWK/Computermusik/data-composition/datamodules :l TemperatureData HumidityData BatteryData +-- Load Data. This currently is pinned to my setup. +import TemperatureData +import HumidityData +import BatteryData + + +-- Normal Tidal Startup from here on tidal <- startTidal (superdirtTarget {oLatency = 0.05, oAddress = "127.0.0.1", oPort = 57120}) (defaultConfig {cVerbose = True, cFrameTimespan = 1/20}) :{ @@ -88,6 +105,21 @@ let getState = streamGet tidal setB = streamSetB tidal :} + +-- Custom Functions +:{ +let getRawValueList tableData = map (\x -> snd x) tableData + getRawLabelList tableData = map (\x -> fst x) tableData + makePlottableList list = zip [0..] list + plotPlainList list = plotListStyle [] (defaultStyle {plotType = LinesPoints, lineSpec = CustomStyle [LineTitle "Numerical Value", LineWidth 3, PointType 7, PointSize 3]}) $ makePlottableList list + getNum value scalar = fromInteger $ round $ (maybe 0.0 id (readMaybe value :: Maybe Float)) * scalar + listToNum list = map (\x -> getNum x 1) list + sliceAt start length list = take length (drop start list) + normalize max list = map (\x -> fromIntegral ( round ( max * ( x / (maximum list))))) list + normalizeAt zero max list = map (\x -> fromIntegral ( round ( max * ((x - zero)/ (maximum (map (\y -> y - zero) list)))))) list + scaleBetween low high max list = map (\x -> fromIntegral ( round (max * ((x - low)/ (high - low))))) list +:} + :set prompt "tidal> " :set prompt-cont "" diff --git a/configs/superdirt_startup.scd b/configs/superdirt_startup.scd new file mode 100644 index 0000000..df4a84a --- /dev/null +++ b/configs/superdirt_startup.scd @@ -0,0 +1,54 @@ +/* +This is an example startup file. +If you want to modify it, best copy it elsewhere to keep the git repository clean. + +You can then load it by calling +"path/to/my/superdirt_startup.scd".load +from the supercollider startup file + +The supercollider startup file is to be found in +Platform.userAppSupportDir +/+ "startup.scd", +or via the menu File > Open startup file +*/ + + +( +s.reboot { // server options are only updated on reboot + // configure the sound server: here you could add hardware specific options + // see http://doc.sccode.org/Classes/ServerOptions.html + s.options.numBuffers = 1024 * 256; // increase this if you need to load more samples + s.options.memSize = 8192 * 32; // increase this if you get "alloc failed" messages + s.options.numWireBufs = 64; // increase this if you get "exceeded number of interconnect buffers" messages + s.options.maxNodes = 1024 * 32; // increase this if you are getting drop outs and the message "too many nodes" + s.options.numOutputBusChannels = 2; // set this to your hardware output channel size, if necessary + s.options.numInputBusChannels = 2; // set this to your hardware output channel size, if necessary + // boot the server and start SuperDirt + s.waitForBoot { + ~dirt.stop; // stop any old ones, avoid duplicate dirt (if it is nil, this won't do anything) + ~dirt = SuperDirt(2, s); // two output channels, increase if you want to pan across more channels + ~dirt.loadSoundFiles(thisProcess.nowExecutingPath.dirname +/+ "../samples/*"); // load custom samples + ~dirt.loadSoundFiles; // load samples (path containing a wildcard can be passed in) + s.sync; // wait for samples to be read + ~dirt.start(57120, 0 ! 12); // start listening on port 57120, create two busses each sending audio to channel 0 + + // optional, needed for convenient access from sclang: + ( + ~d1 = ~dirt.orbits[0]; ~d2 = ~dirt.orbits[1]; ~d3 = ~dirt.orbits[2]; + ~d4 = ~dirt.orbits[3]; ~d5 = ~dirt.orbits[4]; ~d6 = ~dirt.orbits[5]; + ~d7 = ~dirt.orbits[6]; ~d8 = ~dirt.orbits[7]; ~d9 = ~dirt.orbits[8]; + ~d10 = ~dirt.orbits[9]; ~d11 = ~dirt.orbits[10]; ~d12 = ~dirt.orbits[11]; + ); + + // directly below here, in your own copy of this file, you could add further code that you want to call on startup + // this makes sure the server and ~dirt are running + // you can keep this separate and make it easier to switch between setups + // by using "path/to/my/file.scd".load and if necessary commenting out different load statements + // ... + + }; + + s.latency = 0.3; // increase this if you get "late" messages + + +}; +); diff --git a/performance_prep/base.tidal b/performance_prep/base.tidal new file mode 100644 index 0000000..e56d007 --- /dev/null +++ b/performance_prep/base.tidal @@ -0,0 +1,47 @@ +let temperatureScalar = 10 + temperaturePattern = scale "major" (fromList (map (\x -> getNum x temperatureScalar) (map (\x -> snd x) (take 10 temperaturedata))) |- 150) + temperature = fast 4 $ n ("x(3,5)" |> temperaturePattern + "['maj | 'min]" )# s "superpiano" # room 0.5 + in d1 $ temperature + +queryArc (n ("1 2 3 4 5 6 7 8")) (Arc 0 1) + +:i fromInteger + +:t temperaturedata + +length $ listToNum $ getRawValueList $ temperaturedata + +plotList [] (zip [0..] (listToNum (getRawValueList $ take 10 temperaturedata))) + +:t temperaturedata + + +selection = listToNum (getRawValueList $ take 10 temperaturedata) + +plotPlainList (selection) + + +let batteryScalar = 5 + batteryPattern = scale "major" (fromList (map (\x -> getNum x batteryScalar) (map (\x -> snd x) (sliceList 500 510 batterydata))) |- 150) + battery = n ("x(3,5)" |> batteryPattern + "['maj | 'min]" )# s "jvbass" # room 0.5 + in d2 $ battery + +battery = n ("x(3,5)" |> batteryPattern + "['maj | 'min]" ) +batteryScalar = 5 +queryArc battery (Arc 0 2) + +queryArc temperature (Arc 0 2.5) + +d1 $ fast 10 $ append (n (fromList (map (\x -> fromInteger (round ((getFloat x)*10))) (map (\x -> snd x) (take 100 temperaturedata))))) ("~!10") # s "jvbass" # room 0.5 # delay 0.7 + +d2 $ fast 10 $ n (fromList (map (\x -> fromInteger (round ((getFloat x)*5))) (map (\x -> snd x) (take 100 humiditydata)))) # s "arpy" # room 0.5 # delay 0.7 + +d1 $ trigger $ s "" + +d1 $ n ( run 10) # s "v" +:t map (\x -> getMaybeFloat (snd x)) (take 100 temperaturedata) + +d1 $ n("c'maj f4'maj'ii g4'maj'i c'maj") # s "superpiano" + +d1 $ slow 4 $ n "[1..5]" # s "meteo" + diff --git a/scratchpads/lists.tidal b/performance_prep/base_with_everything.tidal similarity index 87% rename from scratchpads/lists.tidal rename to performance_prep/base_with_everything.tidal index bfd6107..282f823 100644 --- a/scratchpads/lists.tidal +++ b/performance_prep/base_with_everything.tidal @@ -44,6 +44,19 @@ getNum :: String -> Float -> Float getNum value scalar = fromInteger $ round $ (maybe 0.0 id (readMaybe value :: Maybe Float)) * scalar sliceList start end list = take (end - start + 1) (drop start list) +normalizeBetween :: Int Int [Float] -> [Float] +normalizeBetween min max list = map (\x -> (max - min) * ((x - min)/ (maximum (map (\y -> y - min) list)))) list + +normalizeAt :: Int Int [Float] -> [Float] +normalizeAt zero max list = map (\x -> max * ((x - zero)/ (maximum (map (\y -> y - zero) list)))) list + + + +map (\x -> max * ( x / (maximum list))) list + + +maximum [1,2,3,4,5] + let temperatureScalar = 10 temperaturePattern = scale "major" (fromList (map (\x -> getNum x temperatureScalar) (map (\x -> snd x) (take 10 temperaturedata))) |- 150) @@ -54,9 +67,6 @@ queryArc (n ("1 2 3 4 5 6 7 8")) (Arc 0 1) :i fromInteger - -getRawLabelList temper - :t temperaturedata length $ listToNum $ getRawValueList $ temperaturedata @@ -93,3 +103,4 @@ d1 $ n ( run 10) # s "v" d1 $ n("c'maj f4'maj'ii g4'maj'i c'maj") # s "superpiano" +d1 $ slow 4 $ n "[1..5]" # s "meteo" \ No newline at end of file diff --git a/samples/meteo/1.wav b/samples/meteo/1.wav new file mode 100644 index 0000000..78b492c Binary files /dev/null and b/samples/meteo/1.wav differ diff --git a/samples/meteo/2.wav b/samples/meteo/2.wav new file mode 100644 index 0000000..1fda101 Binary files /dev/null and b/samples/meteo/2.wav differ diff --git a/samples/meteo/3.wav b/samples/meteo/3.wav new file mode 100644 index 0000000..1f6aea1 Binary files /dev/null and b/samples/meteo/3.wav differ diff --git a/samples/meteo/4.wav b/samples/meteo/4.wav new file mode 100644 index 0000000..bfa3d31 Binary files /dev/null and b/samples/meteo/4.wav differ diff --git a/samples/meteo/5.wav b/samples/meteo/5.wav new file mode 100644 index 0000000..72c2dd0 Binary files /dev/null and b/samples/meteo/5.wav differ diff --git a/tools/superdirt.sh b/tools/superdirt.sh index 58d5586..12f9b25 100755 --- a/tools/superdirt.sh +++ b/tools/superdirt.sh @@ -1,4 +1,8 @@ #!/bin/bash -# Make SuperCollider construct the Path to the default SuperDirt startup file and load it. -# Afterwards direct stdin to sclang so we can control it. -(echo -e 'load(Platform.userAppSupportDir+/+"/downloaded-quarks/SuperDirt/superdirt_startup.scd")' && cat) | sclang \ No newline at end of file +# Load Supercollider with custom SuperDirt startup script +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") +PROJECTBASEDIR=$(dirname "$SCRIPTPATH") + +cd "$PROJECTBASEDIR/configs" || exit +sclang "$PROJECTBASEDIR/configs/superdirt_startup.scd" \ No newline at end of file diff --git a/tools/tidal.sh b/tools/tidal.sh index c1bfcd2..777b3cb 100755 --- a/tools/tidal.sh +++ b/tools/tidal.sh @@ -1,3 +1,9 @@ #!/bin/sh -ghci -ghci-script ../scratchpads/BootTidal.hs + +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") +PROJECTBASEDIR=$(dirname "$SCRIPTPATH") + +ghci -ghci-script "$PROJECTBASEDIR/configs/BootTidal.hs" + diff --git a/tools/troop_client_with_tidal_interpreter.sh b/tools/troop_client_with_tidal_interpreter.sh index 813dd4c..2be5a85 100755 --- a/tools/troop_client_with_tidal_interpreter.sh +++ b/tools/troop_client_with_tidal_interpreter.sh @@ -2,7 +2,8 @@ # Script location SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") +PROJECTBASEDIR=$(dirname "$SCRIPTPATH") cd "$SCRIPTPATH"/Troop || exit # Explicit python version is on purpose, Troop won't work with python 3.11+ -python3.10 run-client.py --cli --syntax "tidalcycles" --mode $(which ghci) --args "-ghci-script $SCRIPTPATH/BootTidal.hs" \ No newline at end of file +python3.10 run-client.py --cli --syntax "tidalcycles" --mode $(which ghci) --args "-ghci-script $PROJECTBASEDIR/configs/BootTidal.hs" \ No newline at end of file diff --git a/tools/troop_server.sh b/tools/troop_server.sh index 255528c..b922060 100755 --- a/tools/troop_server.sh +++ b/tools/troop_server.sh @@ -6,4 +6,4 @@ PROJECTBASEDIR=$(dirname "$SCRIPTPATH") cd "$SCRIPTPATH"/Troop || exit # Explicit python version is on purpose, Troop won't work with python 3.11+ -python3.10 run-server.py \ No newline at end of file +python3.10 run-server.py --password "" \ No newline at end of file