Upload current attempts

This commit is contained in:
Phillip Kühne 2024-02-04 20:14:13 +01:00
parent f398084692
commit ac2cc81ce1
Signed by: phillip
GPG Key ID: E4C1C4D2F90902AA
12 changed files with 64667 additions and 0 deletions

24
.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
# cabal
dist
dist-*
cabal-dev
*.o
*.hi
*.hie
*.chi
*.chs.h
*.dyn_o
*.dyn_hi
.hpc
.hsenv
.cabal-sandbox/
cabal.sandbox.config
*.prof
*.aux
*.hp
*.eventlog
.stack-work/
cabal.project.local
cabal.project.local~
.HTF/
.ghc.environment.*

4
app/Main.hs Normal file
View File

@ -0,0 +1,4 @@
module Main where
main :: IO ()
main = putStrLn "Hello, Haskell!"

81
data-composition.cabal Normal file
View File

@ -0,0 +1,81 @@
cabal-version: 3.0
-- The cabal-version field refers to the version of the .cabal specification,
-- and can be different from the cabal-install (the tool) version and the
-- Cabal (the library) version you are using. As such, the Cabal (the library)
-- version used must be equal or greater than the version stated in this field.
-- Starting from the specification version 2.2, the cabal-version field must be
-- the first thing in the cabal file.
-- Initial package description 'data-composition' generated by
-- 'cabal init'. For further documentation, see:
-- http://haskell.org/cabal/users-guide/
--
-- The name of the package.
name: data-composition
-- The package version.
-- See the Haskell package versioning policy (PVP) for standards
-- guiding when and how versions should be incremented.
-- https://pvp.haskell.org
-- PVP summary: +-+------- breaking API changes
-- | | +----- non-breaking API additions
-- | | | +--- code changes with no API change
version: 0.1.0.0
-- A short (one-line) description of the package.
-- synopsis:
-- A longer description of the package.
-- description:
-- The license under which the package is released.
license: MIT
-- The file containing the license text.
license-file: LICENSE
-- The package author(s).
author: Phillip Kühne
-- An email address to which users can send suggestions, bug reports, and patches.
maintainer: phillip.kuehne@stud.htwk-leipzig.de
-- A copyright notice.
-- copyright:
build-type: Simple
-- Extra doc files to be distributed with the package, such as a CHANGELOG or a README.
extra-doc-files: CHANGELOG.md
-- Extra source files to be distributed with the package, such as examples, or a tutorial module.
-- extra-source-files:
common warnings
ghc-options: -Wall
executable data-composition
-- Import common warning flags.
import: warnings
-- .hs or .lhs file containing the Main module.
main-is: Main.hs
-- Modules included in this executable, other than Main.
-- other-modules: csv
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
-- Other library packages from which modules are imported.
build-depends: base ^>=4.17.2.1,
bytestring,
cassava,
vector,
directory,
time
-- Directories containing source files.
hs-source-dirs: app
-- Base language which the package is written in.
default-language: GHC2021

9523
scratchpads/BatteryData.hs Normal file

File diff suppressed because it is too large Load Diff

87
scratchpads/BootTidal.hs Normal file
View File

@ -0,0 +1,87 @@
:set -XOverloadedStrings
:set prompt ""
import Sound.Tidal.Context
import System.IO (hSetEncoding, stdout, utf8)
hSetEncoding stdout utf8
-- Load Data
:l TemperatureData
-- :l HumidityData
-- :l BatteryData
tidal <- startTidal (superdirtTarget {oLatency = 0.05, oAddress = "127.0.0.1", oPort = 57120}) (defaultConfig {cVerbose = True, cFrameTimespan = 1/20})
:{
let only = (hush >>)
p = streamReplace tidal
hush = streamHush tidal
panic = do hush
once $ sound "superpanic"
list = streamList tidal
mute = streamMute tidal
unmute = streamUnmute tidal
unmuteAll = streamUnmuteAll tidal
unsoloAll = streamUnsoloAll tidal
solo = streamSolo tidal
unsolo = streamUnsolo tidal
once = streamOnce tidal
first = streamFirst tidal
asap = once
nudgeAll = streamNudgeAll tidal
all = streamAll tidal
resetCycles = streamResetCycles tidal
setCycle = streamSetCycle tidal
setcps = asap . cps
getcps = streamGetcps tidal
getnow = streamGetnow tidal
xfade i = transition tidal True (Sound.Tidal.Transition.xfadeIn 4) i
xfadeIn i t = transition tidal True (Sound.Tidal.Transition.xfadeIn t) i
histpan i t = transition tidal True (Sound.Tidal.Transition.histpan t) i
wait i t = transition tidal True (Sound.Tidal.Transition.wait t) i
waitT i f t = transition tidal True (Sound.Tidal.Transition.waitT f t) i
jump i = transition tidal True (Sound.Tidal.Transition.jump) i
jumpIn i t = transition tidal True (Sound.Tidal.Transition.jumpIn t) i
jumpIn' i t = transition tidal True (Sound.Tidal.Transition.jumpIn' t) i
jumpMod i t = transition tidal True (Sound.Tidal.Transition.jumpMod t) i
jumpMod' i t p = transition tidal True (Sound.Tidal.Transition.jumpMod' t p) i
mortal i lifespan release = transition tidal True (Sound.Tidal.Transition.mortal lifespan release) i
interpolate i = transition tidal True (Sound.Tidal.Transition.interpolate) i
interpolateIn i t = transition tidal True (Sound.Tidal.Transition.interpolateIn t) i
clutch i = transition tidal True (Sound.Tidal.Transition.clutch) i
clutchIn i t = transition tidal True (Sound.Tidal.Transition.clutchIn t) i
anticipate i = transition tidal True (Sound.Tidal.Transition.anticipate) i
anticipateIn i t = transition tidal True (Sound.Tidal.Transition.anticipateIn t) i
forId i t = transition tidal False (Sound.Tidal.Transition.mortalOverlay t) i
d1 = p 1 . (|< orbit 0)
d2 = p 2 . (|< orbit 1)
d3 = p 3 . (|< orbit 2)
d4 = p 4 . (|< orbit 3)
d5 = p 5 . (|< orbit 4)
d6 = p 6 . (|< orbit 5)
d7 = p 7 . (|< orbit 6)
d8 = p 8 . (|< orbit 7)
d9 = p 9 . (|< orbit 8)
d10 = p 10 . (|< orbit 9)
d11 = p 11 . (|< orbit 10)
d12 = p 12 . (|< orbit 11)
d13 = p 13
d14 = p 14
d15 = p 15
d16 = p 16
:}
:{
let getState = streamGet tidal
setI = streamSetI tidal
setF = streamSetF tidal
setS = streamSetS tidal
setR = streamSetR tidal
setB = streamSetB tidal
:}
:set prompt "tidal> "
:set prompt-cont ""
default (Pattern String, Integer, Double)

21557
scratchpads/HumidityData.hs Normal file

File diff suppressed because it is too large Load Diff

33297
scratchpads/TemperatureData.hs Normal file

File diff suppressed because it is too large Load Diff

44
scratchpads/csv.hs Normal file
View File

@ -0,0 +1,44 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
-- This requires my custom BootTidal.hs
import Prelude hiding (filter)
import qualified Data.ByteString.Lazy as BL
import Data.Csv -- this is from the Cassava library
import qualified Data.Vector as V
-- import System.Directory (doesFileExist)
-- import Text.Printf
-- import Control.Monad (forM_)
import GHC.IO.Exception
import Control.Exception (try)
data TimestampedDatum = TimestampedDatum {
timestamp :: String,
datum :: Float
} deriving Show
dataPath = "../data/weather/balcony_temperature.csv"
instance FromNamedRecord TimestampedDatum where
parseNamedRecord r =
TimestampedDatum
<$> r .: "time"
<*> r .: "C.value"
type ErrorMsg = String
type CsvData = (Header, V.Vector TimestampedDatum)
parseCsv :: FilePath -> IO (Either ErrorMsg CsvData)
parseCsv filePath = do
result <- try $ BL.readFile filePath
return $ case result of
Left (exception :: IOException) -> Left $ show exception
Right contents -> decodeByName contents
getList :: CsvData -> V.Vector TimestampedDatum
getList = snd
-- getValue :: TimestampedDatum -> Float
-- getValue = datum

View File

@ -0,0 +1,5 @@
-- Quantized Perlin Noise for as a test
d7 $ s "superpiano*2" # n (quantise 1 (perlin * 10))
-- Why does the following not work then???
d7 $ s "superpiano*2" # n (scale "major" (perlin * 10))

View File

@ -0,0 +1,6 @@
import TemperatureData
data ValueRecord a = ValueRecord {
time :: Data.Time.UTCTime,
value :: a
}

5
scratchpads/lists.tidal Normal file
View File

@ -0,0 +1,5 @@
d1 $ s "bd"
map snd $ take 10 $ temperaturedata

34
tools/transform_data.py Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Helper functions to transform data from CSV files into haskell files
import csv
import os
import sys
import re
def transform_data(input_file, output_file):
filename:str= os.path.splitext(os.path.basename(output_file))[0]
with open(input_file, 'r') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
with open(output_file, 'w') as f:
f.write('module '+filename+' where\n')
f.write(filename.lower()+' = [\n')
for row in reader:
if reader.line_num == 1:
continue
if reader.line_num == 2:
if len(row) > 0:
f.write(' ("' + row[0] + '", "' + row[1] + '")')
else:
if len(row) > 0:
f.write(',\n ("' + row[0] + '", "' + row[1] + '")')
f.write('\n ]\n')
f.close()
print('Data transformed from ' + input_file + ' to ' + output_file)
if __name__ == '__main__':
if len(sys.argv) < 3:
print('Usage: transform_data.py input_file output_file')
else:
transform_data(sys.argv[1], sys.argv[2])