-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Sintrastes/xen-toolbox
- Loading branch information
Showing
42 changed files
with
601 additions
and
2,565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
dist | ||
dist-* | ||
cabal-dev | ||
*~ | ||
*.o | ||
*.hi | ||
*.chi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM ubuntu:xenial | ||
MAINTAINER "Nathan Bedell" "nbedell@tulane.edu" | ||
CMD apt -y update | ||
CMD apt -y install ghc \ | ||
cabal-install \ | ||
git \ | ||
software-properties-common | ||
CMD add-apt-repository -y ppa:hvr/ghc | ||
CMD apt update | ||
CMD apt -y install ghc-8.4.1 | ||
CMD cabal update | ||
WORKDIR /root/data/ | ||
CMD git clone https://github.com/Sintrastes/xen-toolbox | ||
WORKDIR /root/data/xen-toolbox/ | ||
CMD cabal install --with-ghc=/opt/ghc/bin/ghc-8.4.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
module Data.Scores where | ||
|
||
-- | ||
-- Important type definitions for working with representations of scores | ||
-- | ||
|
||
import Vivid | ||
import Scales.Generic | ||
|
||
-- Note: Some of the definitions here have to do with playback, | ||
-- so it would probably be good to have them in a seperate Data.Scores.Playback | ||
-- module | ||
|
||
type Vol = Double | ||
type Duration = Rational | ||
data Inst = VividSynth (Vol -> SynthDef '["note"]) | FluidInst String Int | ||
data Line' note = Line' Inst [(Maybe (note, Vol), Duration)] | ||
type Score' note = [Line' note] | ||
|
||
-- some useful type synonyms | ||
-- Note: I'll want to refactor types such as Line22 out of the codebase eventually | ||
type Line note = [(note, Rational)] | ||
type Score note = [Line note] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
module Data.Scores.Util where | ||
|
||
-- | ||
-- A module for utility functions designed for manipulating | ||
-- different representations of scores. | ||
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{-# LANGUAGE MultiParamTypeClasses, KindSignatures, TypeOperators, TypeFamilies, FlexibleInstances, DataKinds, ExtendedDefaultRules, UndecidableInstances, GADTs, AllowAmbiguousTypes, TypeInType, ScopedTypeVariables, FunctionalDependencies, QuasiQuotes, TemplateHaskell #-} | ||
|
||
module Data.Xentools.ExampleScores where | ||
|
||
import Scales.Generic | ||
import Scales.Transformations | ||
import Data.Semiring | ||
import Synths.MyVividSynths | ||
import Parsers.Eq22 | ||
import Parsers.Eq24 | ||
import Parsers.BP | ||
|
||
exBPScore = [Line' (VividSynth tone) | ||
(atVolume 1 ([lineBP| C3 1, D3 1, E3 1, F3 1, G3 1, H3 1, J3 1, A3 1, B3 1, C4 4 |] :: Line NoteBP)), | ||
Line' (VividSynth tone) | ||
(atVolume 1 ([lineBP| E3 4, F3 4, C3 5 |])), | ||
Line' (VividSynth tone) | ||
(atVolume 1 ([lineBP| G3 4, J3 4, E3 5 |]))] | ||
|
||
-- The same example, but written with the withInst function | ||
-- exscore1' :: Score Note22 | ||
{- | ||
exscore1' = [ withInst 0.3 (VividSynth additiveSynth) ([line22| C4 2, D4 2, EQes4 1, BQes3 1, C4 4, C4 2, D4 2, EQes4 1, BQes3 1, C4 8 |] :: Line Note22) | ||
, withInst 0.5 (VividSynth tone) ([line22| C5 3, D5 1, EQes5 4, F5 2, DQes5 2, EQes5 4, EQes4 8 |] :: Line Note22) | ||
, withInst 0.4 (FluidInst "test.sf3" 17) ([line22| C4 2, C4 2, C4 2, C4 2, C4 16 |] :: Line Note22) | ||
, withInst 0.4 (FluidInst "test.sf3" 17) ([line22| EQes3 2, EQes3 2, EQes3 2, EQes3 2, EQes3 16 |] :: Line Note22) | ||
, withInst 0.4 (FluidInst "test.sf3" 17) ([line22| G4 2, G4 2, G4 2, G4 2, G4 16 |] :: Line Note22) | ||
] | ||
-} | ||
|
||
ex22EdoScore1 = [Line' (VividSynth additiveSynth) | ||
(atVolume 0.3 ([line22| C4 2, D4 2, EQes4 1, BQes3 1, C4 4, C4 2, D4 2, EQes4 1, BQes3 1, C4 8 |] :: Line Note22) ), | ||
Line' (VividSynth tone) | ||
(atVolume 0.5 ([line22| C5 3, D5 1, EQes5 4, F5 2, DQes5 2, EQes5 4, EQes4 8 |])), | ||
Line' (FluidInst "test.sf3" 17) | ||
(atVolume 0.4 ([line22| C4 2, C4 2, C4 2, C4 2, C4 16 |])), | ||
Line' (FluidInst "test.sf3" 17) | ||
(atVolume 0.4 ([line22| EQes3 2, EQes3 2, EQes3 2, EQes3 2, EQes3 16 |])), | ||
Line' (FluidInst "test.sf3" 17) | ||
(atVolume 0.4 ([line22| G4 2, G4 2, G4 2, G4 2, G4 16 |])) | ||
--Line' (FluidInst "test.sf3" 9) | ||
-- (atVolume 1 ([line22| C6 4, EQes6 4, F6 4, DQes6 4, C6 8 |])) | ||
] | ||
|
||
ex22EdoScore2 = [Line' (VividSynth additiveSynth) | ||
(atVolume 0.3 ([line22| C4 2, D4 2, EQes4 1, BQes3 1, C4 4, C4 2, D4 2, EQes4 1, BQes3 1, C4 8 |] :: Line Note22) ), | ||
Line' (VividSynth tone) | ||
(atVolume 0.5 ([line22| C5 3, D5 1, EQes5 4, F5 2, DQes5 2, EQes5 4, EQes4 8 |])), | ||
Line' (FluidInst "test.sf3" 17) | ||
(atVolume 0.4 ([line22| C4 2, C4 2, C4 2, C4 2, C4 16 |])), | ||
Line' (FluidInst "test.sf3" 17) | ||
(atVolume 0.4 ([line22| EQes3 2, EQes3 2, EQes3 2, EQes3 2, EQes3 16 |])), | ||
Line' (FluidInst "test.sf3" 17) | ||
(atVolume 0.4 ([line22| G4 2, G4 2, G4 2, G4 2, G4 16 |])) | ||
--Line' (FluidInst "test.sf3" 9) | ||
-- (atVolume 1 ([line22| C6 4, EQes6 4, F6 4, DQes6 4, C6 8 |])) | ||
] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
module IO.Fluidsynth.Sequencer where | ||
|
||
import IO.Fluidsynth.Util | ||
|
||
sequenceNotesFluid :: (TuningSystem note g, Show note) | ||
=> Socket | ||
-> Int -- Program number | ||
-> String -- Soundfont name | ||
-> Score note -- [[note]] | ||
-> Int -- Midi note velocity as volume | ||
-> Tempo | ||
-> Int -- Offset (for debug) | ||
-> Preformance | ||
sequenceNotesFluid socket prog sft | ||
score vol bpm o = Preformance (do mapConcurrently go (zip score [0..n-1]) | ||
return ()) | ||
where n = length score -- number of midi channels we need to use | ||
bps = bpm/60 | ||
-- There's some strange scoping issue with this line | ||
-- I can't uncomment this for some reason | ||
-- run :: Line note -> Preformance | ||
go (line, i) = (forM_ line (\(n, duration) -> | ||
do setProgram socket (i + o) prog | ||
microNoteOn socket (i + o) (nfreq n) vol | ||
Vivid.wait $ (fromRational duration) * (1/bps) | ||
microNoteOff socket (i + o) (nfreq n))) | ||
|
||
sequenceLineFluid :: TuningSystem note g | ||
=> Socket | ||
-> (String, Int) -- Fluid instrument data (Note, this might need to change, I'm not sure if | ||
-- we can easily use more than one SF file at once | ||
-> [(Maybe (note, Vol), Rational)] -- Preformance data | ||
-> Int -- Channel number | ||
-> Tempo | ||
-> Preformance | ||
sequenceLineFluid socket (sfpath, prog) line n bpm = | ||
Preformance (forM_ line (\(noteType, duration) -> | ||
case noteType of | ||
Just (note, vol) -> do putStrLn "Sequencing a fluid note" | ||
setProgram socket n prog | ||
microNoteOn socket n (nfreq note) (volToVel vol) | ||
Vivid.wait $ (fromRational duration) * (1/bps) | ||
putStrLn "Sequencing a fluid note (done waiting)" | ||
microNoteOff socket n (nfreq note) | ||
Nothing -> do Vivid.wait $ (fromRational duration) * (1/bps))) | ||
where bps = (bpm/60) :: Double |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
module IO.Fluidsynth.Util where | ||
|
||
setProgram :: Socket -> Int -> Int -> IO () | ||
setProgram socket channel prog = send socket (C.pack $ "prog "++show channel++" "++show prog++"\n") | ||
|
||
openServer :: Int -> Int -> IO () | ||
openServer channels port = do | ||
system $ "fluidsynth -K "++ show channels ++" -j -i -s -o \"shell.port="++show port++"\"" | ||
return () | ||
|
||
loadSoundFont :: Socket -> String -> IO () | ||
loadSoundFont socket filepath = send socket (C.pack $ "load "++show filepath++"\n") | ||
|
||
noteOn :: Socket -> Int -> Int -> Int -> IO () | ||
noteOn socket channel note vel = send socket (C.pack $ "noteon "++show channel++" "++show note++" "++show vel++"\n") | ||
|
||
noteOff :: Socket -> Int -> Int -> IO () | ||
noteOff socket channel note = send socket (C.pack $ "noteoff "++show channel++" "++show note++"\n") | ||
|
||
pitchBendSet :: Socket -> Int -> Int -> IO () | ||
pitchBendSet socket channel value = send socket (C.pack $ "pitch_bend "++show channel++" "++show value++"\n") | ||
|
||
microNoteOn :: Socket -> Int -> Double -> Int -> IO () | ||
microNoteOn socket channel note vel = | ||
do pitchBendSet socket channel (round $ (note - (fromIntegral $ floor note))/pbu') | ||
noteOn socket channel (floor note) vel | ||
|
||
microNoteOff :: Socket -> Int -> Double -> IO () | ||
microNoteOff socket channel note = | ||
do send socket (C.pack $ "noteoff "++show channel++" "++show (floor note)++"\n") | ||
return () | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
module IO.Vivid.Sequencer | ||
|
||
sequenceLineVivid :: TuningSystem note g | ||
=> (Double -> SynthDef '["note"]) | ||
-> [(Maybe (note, Double), Rational)] -- Preformance data1 | ||
-> Tempo | ||
-> Preformance | ||
sequenceLineVivid syn line bpm = run line | ||
where bps = bpm/60 | ||
run line = Preformance | ||
(forM_ line (\(noteType, duration) -> | ||
case noteType of | ||
Just (note, vol) -> do putStrLn "Sequencing a Vivid note" | ||
s <- synth (syn vol) (50::I "note") | ||
set s (toI (nfreq note) :: I "note") | ||
Vivid.wait $ (fromRational duration) * (1/bps) | ||
putStrLn "Sequencing a Vivid note (done waiting)" | ||
free s | ||
Nothing -> do Vivid.wait $ (fromRational duration) * (1/bps))) | ||
|
||
|
||
-- Note: This isn't really even needed anymore. | ||
sequenceNotes :: TuningSystem note g | ||
=> SynthDef '["note"] | ||
-> Score note | ||
-> Volume | ||
-> Tempo | ||
-> Preformance | ||
sequenceNotes syn score vol bpm = foldr1 (<>) (map run score) | ||
where bps = bpm/60 | ||
run line = Preformance (forM_ line (\(n, duration) -> | ||
do s <- synth syn (50::I "note") | ||
set s (toI (nfreq n) :: I "note") | ||
Vivid.wait $ (fromRational duration) * (1/bps) | ||
free s)) |
Oops, something went wrong.