module Csound.Air.Wav(
readSnd, loopSnd, loopSndBy,
readWav, loopWav, readSegWav,
tempoLoopWav, tempoReadWav,
readSnd1, loopSnd1, loopSndBy1,
readWav1, loopWav1, readSegWav1,
tempoLoopWav1, tempoReadWav1,
LoopMode(..), ramSnd, ramSnd1,
ramTab, mincer, temposcal,
Phsr(..), lphase, relPhsr, sndPhsr, phsrBounce, phsrOnce,
ram, ram1,
Fidelity, TempoSig, PitchSig,
readRam, loopRam, readSeg, loopSeg, readRel, loopRel,
readRam1, loopRam1, readSeg1, loopSeg1, readRel1, loopRel1,
scaleDrum, scaleHarm, scaleDrum1, scaleHarm1, scaleWav1, scaleWav,
SampleFormat(..),
writeSigs, writeWav, writeAiff, writeWav1, writeAiff1,
dumpWav, dumpWav1,
lengthSnd, segments,
takeSnd, delaySnd, afterSnd, lineSnd, loopLineSnd, segmentSnd, repeatSnd, toMono
) where
import Data.List(isSuffixOf)
import Data.Default
import Data.Boolean
import Temporal.Media
import Csound.Dynamic hiding (int, Sco)
import Csound.Typed
import Csound.Typed.Opcode hiding (tempo, pitch, metro, tab)
import Csound.Tab(mp3s, mp3Left, wavs, wavLeft, WavChn(..), Mp3Chn(..))
import Csound.Control.Instr(withDur)
import Csound.Control.Evt(metro, loadbang)
import Csound.Air.Spec
takeSnd :: Sigs a => Sig -> a -> a
takeSnd :: Sig -> a -> a
takeSnd Sig
dt a
asig = (Unit -> SE a) -> Evt (Sco Unit) -> a
forall a b. (Arg a, Sigs b) => (a -> SE b) -> Evt (Sco a) -> b
sched (SE a -> Unit -> SE a
forall a b. a -> b -> a
const (SE a -> Unit -> SE a) -> SE a -> Unit -> SE a
forall a b. (a -> b) -> a -> b
$ a -> SE a
forall (m :: * -> *) a. Monad m => a -> m a
return a
asig) (Evt (Sco Unit) -> a) -> Evt (Sco Unit) -> a
forall a b. (a -> b) -> a -> b
$ Sig -> Evt Unit -> Evt (Sco Unit)
forall a. Sig -> Evt a -> Evt (Sco a)
withDur Sig
dt (Evt Unit -> Evt (Sco Unit)) -> Evt Unit -> Evt (Sco Unit)
forall a b. (a -> b) -> a -> b
$ Evt Unit
loadbang
delaySnd :: Sigs a => Sig -> a -> a
delaySnd :: Sig -> a -> a
delaySnd Sig
dt = Sig -> Sig -> a -> a
forall a. Sigs a => Sig -> Sig -> a -> a
segmentSnd Sig
dt Sig
forall a. Num a => a
infiniteDur
segmentSnd ::Sigs a => Sig -> Sig -> a -> a
segmentSnd :: Sig -> Sig -> a -> a
segmentSnd Sig
dt Sig
durS a
asig = (Unit -> SE a) -> Evt (Sco Unit) -> a
forall a b. (Arg a, Sigs b) => (a -> SE b) -> Evt (Sco a) -> b
sched (SE a -> Unit -> SE a
forall a b. a -> b -> a
const (SE a -> Unit -> SE a) -> SE a -> Unit -> SE a
forall a b. (a -> b) -> a -> b
$ a -> SE a
forall (m :: * -> *) a. Monad m => a -> m a
return a
asig) (Evt (Sco Unit) -> a) -> Evt (Sco Unit) -> a
forall a b. (a -> b) -> a -> b
$ (Sco Unit -> Sco Unit) -> Evt (Sco Unit) -> Evt (Sco Unit)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (DurOf (Sco Unit) -> Sco Unit -> Sco Unit
forall a. Delay a => DurOf a -> a -> a
del Sig
DurOf (Sco Unit)
dt) (Evt (Sco Unit) -> Evt (Sco Unit))
-> Evt (Sco Unit) -> Evt (Sco Unit)
forall a b. (a -> b) -> a -> b
$ Sig -> Evt Unit -> Evt (Sco Unit)
forall a. Sig -> Evt a -> Evt (Sco a)
withDur Sig
durS (Evt Unit -> Evt (Sco Unit)) -> Evt Unit -> Evt (Sco Unit)
forall a b. (a -> b) -> a -> b
$ Evt Unit
loadbang
repeatSnd :: Sigs a => Sig -> a -> a
repeatSnd :: Sig -> a -> a
repeatSnd Sig
dt a
asig = (Unit -> SE a) -> Evt (Sco Unit) -> a
forall a b. (Arg a, Sigs b) => (a -> SE b) -> Evt (Sco a) -> b
sched (SE a -> Unit -> SE a
forall a b. a -> b -> a
const (SE a -> Unit -> SE a) -> SE a -> Unit -> SE a
forall a b. (a -> b) -> a -> b
$ a -> SE a
forall (m :: * -> *) a. Monad m => a -> m a
return a
asig) (Evt (Sco Unit) -> a) -> Evt (Sco Unit) -> a
forall a b. (a -> b) -> a -> b
$ Sig -> Evt (Sco Unit)
segments Sig
dt
afterSnd :: (Num b, Sigs b) => Sig -> b -> b -> b
afterSnd :: Sig -> b -> b -> b
afterSnd Sig
dt b
a b
b = Sig -> b -> b
forall a. Sigs a => Sig -> a -> a
takeSnd Sig
dt b
a b -> b -> b
forall a. Num a => a -> a -> a
+ Sig -> b -> b
forall a. Sigs a => Sig -> a -> a
delaySnd Sig
dt b
b
lineSnd :: (Num a, Sigs a) => Sig -> [a] -> a
lineSnd :: Sig -> [a] -> a
lineSnd Sig
dt [a]
xs = (a -> a -> a) -> [a] -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldr1 a -> a -> a
forall b. Sigs b => b -> b -> b
go [a]
xs
where
go :: b -> b -> b
go b
a b
b = Sig -> b -> b -> b
forall b. (Num b, Sigs b) => Sig -> b -> b -> b
afterSnd Sig
dt b
a b
b
loopLineSnd :: (Num a, Sigs a) => Sig -> [a] -> a
loopLineSnd :: Sig -> [a] -> a
loopLineSnd Sig
dt [a]
xs = Sig -> a -> a
forall a. Sigs a => Sig -> a -> a
repeatSnd (Sig
dt Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* (D -> Sig
sig (D -> Sig) -> D -> Sig
forall a b. (a -> b) -> a -> b
$ Int -> D
int (Int -> D) -> Int -> D
forall a b. (a -> b) -> a -> b
$ [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
xs)) (a -> a) -> a -> a
forall a b. (a -> b) -> a -> b
$ Sig -> [a] -> a
forall a. (Num a, Sigs a) => Sig -> [a] -> a
lineSnd Sig
dt [a]
xs
isMp3 :: String -> Bool
isMp3 :: String -> Bool
isMp3 String
name = String
".mp3" String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isSuffixOf` String
name
toMono :: (Sig, Sig) -> Sig
toMono :: (Sig, Sig) -> Sig
toMono (Sig
a, Sig
b) = Sig
0.5 Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* Sig
a Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
+ Sig
0.5 Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* Sig
b
lengthSnd :: String -> D
lengthSnd :: String -> D
lengthSnd String
fileName
| String -> Bool
isMp3 String
fileName = Str -> D
mp3len (Str -> D) -> Str -> D
forall a b. (a -> b) -> a -> b
$ String -> Str
text String
fileName
| Bool
otherwise = Str -> D
filelen (Str -> D) -> Str -> D
forall a b. (a -> b) -> a -> b
$ String -> Str
text String
fileName
segments :: Sig -> Evt (Sco Unit)
segments :: Sig -> Evt (Sco Unit)
segments Sig
dt = Sig -> Evt Unit -> Evt (Sco Unit)
forall a. Sig -> Evt a -> Evt (Sco a)
withDur Sig
dt (Evt Unit -> Evt (Sco Unit)) -> Evt Unit -> Evt (Sco Unit)
forall a b. (a -> b) -> a -> b
$ Sig -> Evt Unit
metro (Sig -> Sig
forall a. Fractional a => a -> a
recip Sig
dt)
readSnd :: String -> (Sig, Sig)
readSnd :: String -> (Sig, Sig)
readSnd String
fileName
| String -> Bool
isMp3 String
fileName = Str -> (Sig, Sig)
mp3in (String -> Str
text String
fileName)
| Bool
otherwise = Str -> (Sig, Sig)
forall a. Tuple a => Str -> a
diskin2 (String -> Str
text String
fileName)
loopSndBy :: Sig -> String -> (Sig, Sig)
loopSndBy :: Sig -> String -> (Sig, Sig)
loopSndBy Sig
dt String
fileName = Sig -> (Sig, Sig) -> (Sig, Sig)
forall a. Sigs a => Sig -> a -> a
repeatSnd Sig
dt ((Sig, Sig) -> (Sig, Sig)) -> (Sig, Sig) -> (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ String -> (Sig, Sig)
readSnd String
fileName
loopSnd :: String -> (Sig, Sig)
loopSnd :: String -> (Sig, Sig)
loopSnd String
fileName = Sig -> String -> (Sig, Sig)
loopSndBy (D -> Sig
sig (D -> Sig) -> D -> Sig
forall a b. (a -> b) -> a -> b
$ String -> D
lengthSnd String
fileName) String
fileName
readWav :: Sig -> String -> (Sig, Sig)
readWav :: Sig -> String -> (Sig, Sig)
readWav Sig
speed String
fileName = Str -> (Sig, Sig)
forall a. Tuple a => Str -> a
diskin2 (String -> Str
text String
fileName) (Sig, Sig) -> Sig -> (Sig, Sig)
forall a. Tuple a => a -> Sig -> a
`withSig` Sig
speed
loopWav :: Sig -> String -> (Sig, Sig)
loopWav :: Sig -> String -> (Sig, Sig)
loopWav Sig
speed String
fileName = ((Sig, Sig) -> [D] -> (Sig, Sig))
-> [D] -> (Sig, Sig) -> (Sig, Sig)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Sig, Sig) -> [D] -> (Sig, Sig)
forall a. Tuple a => a -> [D] -> a
withDs [D
0, D
1] ((Sig, Sig) -> (Sig, Sig)) -> (Sig, Sig) -> (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ (Sig, Sig) -> (Sig, Sig)
ar2 ((Sig, Sig) -> (Sig, Sig)) -> (Sig, Sig) -> (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ Str -> (Sig, Sig)
forall a. Tuple a => Str -> a
diskin2 (String -> Str
text String
fileName) (Sig, Sig) -> Sig -> (Sig, Sig)
forall a. Tuple a => a -> Sig -> a
`withSig` Sig
speed
readSegWav :: D -> D -> Sig -> String -> (Sig, Sig)
readSegWav :: D -> D -> Sig -> String -> (Sig, Sig)
readSegWav D
start D
end Sig
speed String
fileName = Sig -> (Sig, Sig) -> (Sig, Sig)
forall a. Sigs a => Sig -> a -> a
takeSnd (D -> Sig
sig (D -> Sig) -> D -> Sig
forall a b. (a -> b) -> a -> b
$ D
end D -> D -> D
forall a. Num a => a -> a -> a
- D
start) ((Sig, Sig) -> (Sig, Sig)) -> (Sig, Sig) -> (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ (Str -> (Sig, Sig)
forall a. Tuple a => Str -> a
diskin2 (String -> Str
text String
fileName) (Sig, Sig) -> Sig -> (Sig, Sig)
forall a. Tuple a => a -> Sig -> a
`withSig` Sig
speed) (Sig, Sig) -> [D] -> (Sig, Sig)
forall a. Tuple a => a -> [D] -> a
`withDs` [D
start, D
1]
tempoReadWav :: Sig -> String -> (Sig, Sig)
tempoReadWav :: Sig -> String -> (Sig, Sig)
tempoReadWav Sig
speed String
fileName = (Sig -> Sig) -> (Sig, Sig) -> (Sig, Sig)
forall a. SigSpace a => (Sig -> Sig) -> a -> a
mapSig (Sig -> Sig -> Sig
scaleSpec (Sig
1 Sig -> Sig -> Sig
forall a. Fractional a => a -> a -> a
/ Sig -> Sig
forall a. Num a => a -> a
abs Sig
speed)) ((Sig, Sig) -> (Sig, Sig)) -> (Sig, Sig) -> (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ Str -> (Sig, Sig)
forall a. Tuple a => Str -> a
diskin2 (String -> Str
text String
fileName) (Sig, Sig) -> Sig -> (Sig, Sig)
forall a. Tuple a => a -> Sig -> a
`withSig` Sig
speed
tempoLoopWav :: Sig -> String -> (Sig, Sig)
tempoLoopWav :: Sig -> String -> (Sig, Sig)
tempoLoopWav Sig
speed String
fileName = (Sig -> Sig) -> (Sig, Sig) -> (Sig, Sig)
forall a. SigSpace a => (Sig -> Sig) -> a -> a
mapSig (Sig -> Sig -> Sig
scaleSpec (Sig
1 Sig -> Sig -> Sig
forall a. Fractional a => a -> a -> a
/ Sig -> Sig
forall a. Num a => a -> a
abs Sig
speed)) ((Sig, Sig) -> (Sig, Sig)) -> (Sig, Sig) -> (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ ((Sig, Sig) -> [D] -> (Sig, Sig))
-> [D] -> (Sig, Sig) -> (Sig, Sig)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Sig, Sig) -> [D] -> (Sig, Sig)
forall a. Tuple a => a -> [D] -> a
withDs [D
0, D
1] ((Sig, Sig) -> (Sig, Sig)) -> (Sig, Sig) -> (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ (Sig, Sig) -> (Sig, Sig)
ar2 ((Sig, Sig) -> (Sig, Sig)) -> (Sig, Sig) -> (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ Str -> (Sig, Sig)
forall a. Tuple a => Str -> a
diskin2 (String -> Str
text String
fileName) (Sig, Sig) -> Sig -> (Sig, Sig)
forall a. Tuple a => a -> Sig -> a
`withSig` Sig
speed
readSnd1 :: String -> Sig
readSnd1 :: String -> Sig
readSnd1 String
fileName
| String -> Bool
isMp3 String
fileName = (Sig, Sig) -> Sig
toMono ((Sig, Sig) -> Sig) -> (Sig, Sig) -> Sig
forall a b. (a -> b) -> a -> b
$ String -> (Sig, Sig)
readSnd String
fileName
| Bool
otherwise = Str -> Sig
forall a. Tuple a => Str -> a
diskin2 (String -> Str
text String
fileName)
loopSndBy1 :: Sig -> String -> Sig
loopSndBy1 :: Sig -> String -> Sig
loopSndBy1 Sig
dt String
fileName = Sig -> Sig -> Sig
forall a. Sigs a => Sig -> a -> a
repeatSnd Sig
dt (Sig -> Sig) -> Sig -> Sig
forall a b. (a -> b) -> a -> b
$ String -> Sig
readSnd1 String
fileName
loopSnd1 :: String -> Sig
loopSnd1 :: String -> Sig
loopSnd1 String
fileName = Sig -> String -> Sig
loopSndBy1 (D -> Sig
sig (D -> Sig) -> D -> Sig
forall a b. (a -> b) -> a -> b
$ String -> D
lengthSnd String
fileName) String
fileName
readWav1 :: Sig -> String -> Sig
readWav1 :: Sig -> String -> Sig
readWav1 Sig
speed String
fileName = Str -> Sig
forall a. Tuple a => Str -> a
diskin2 (String -> Str
text String
fileName) Sig -> Sig -> Sig
forall a. Tuple a => a -> Sig -> a
`withSig` Sig
speed
loopWav1 :: Sig -> String -> Sig
loopWav1 :: Sig -> String -> Sig
loopWav1 Sig
speed String
fileName = (Sig -> [D] -> Sig) -> [D] -> Sig -> Sig
forall a b c. (a -> b -> c) -> b -> a -> c
flip Sig -> [D] -> Sig
forall a. Tuple a => a -> [D] -> a
withDs [D
0, D
1] (Sig -> Sig) -> Sig -> Sig
forall a b. (a -> b) -> a -> b
$ Str -> Sig
forall a. Tuple a => Str -> a
diskin2 (String -> Str
text String
fileName) Sig -> Sig -> Sig
forall a. Tuple a => a -> Sig -> a
`withSig` Sig
speed
readSegWav1 :: D -> D -> Sig -> String -> Sig
readSegWav1 :: D -> D -> Sig -> String -> Sig
readSegWav1 D
start D
end Sig
speed String
fileName = Sig -> Sig -> Sig
forall a. Sigs a => Sig -> a -> a
takeSnd (D -> Sig
sig (D -> Sig) -> D -> Sig
forall a b. (a -> b) -> a -> b
$ D
end D -> D -> D
forall a. Num a => a -> a -> a
- D
start) (Sig -> Sig) -> Sig -> Sig
forall a b. (a -> b) -> a -> b
$ Str -> Sig
forall a. Tuple a => Str -> a
diskin2 (String -> Str
text String
fileName) Sig -> Sig -> Sig
forall a. Tuple a => a -> Sig -> a
`withSig` Sig
speed Sig -> [D] -> Sig
forall a. Tuple a => a -> [D] -> a
`withDs` [D
start, D
1]
tempoReadWav1 :: Sig -> String -> Sig
tempoReadWav1 :: Sig -> String -> Sig
tempoReadWav1 Sig
speed String
fileName = Sig -> Sig -> Sig
scaleSpec (Sig
1 Sig -> Sig -> Sig
forall a. Fractional a => a -> a -> a
/ Sig -> Sig
forall a. Num a => a -> a
abs Sig
speed) (Sig -> Sig) -> Sig -> Sig
forall a b. (a -> b) -> a -> b
$ Sig -> String -> Sig
readWav1 Sig
speed String
fileName
tempoLoopWav1 :: Sig -> String -> Sig
tempoLoopWav1 :: Sig -> String -> Sig
tempoLoopWav1 Sig
speed String
fileName = Sig -> Sig -> Sig
scaleSpec (Sig
1 Sig -> Sig -> Sig
forall a. Fractional a => a -> a -> a
/ Sig -> Sig
forall a. Num a => a -> a
abs Sig
speed) (Sig -> Sig) -> Sig -> Sig
forall a b. (a -> b) -> a -> b
$ Sig -> String -> Sig
loopWav1 Sig
speed String
fileName
data LoopMode = Once | Loop | Bounce
deriving (Int -> LoopMode -> ShowS
[LoopMode] -> ShowS
LoopMode -> String
(Int -> LoopMode -> ShowS)
-> (LoopMode -> String) -> ([LoopMode] -> ShowS) -> Show LoopMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoopMode] -> ShowS
$cshowList :: [LoopMode] -> ShowS
show :: LoopMode -> String
$cshow :: LoopMode -> String
showsPrec :: Int -> LoopMode -> ShowS
$cshowsPrec :: Int -> LoopMode -> ShowS
Show, LoopMode -> LoopMode -> Bool
(LoopMode -> LoopMode -> Bool)
-> (LoopMode -> LoopMode -> Bool) -> Eq LoopMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoopMode -> LoopMode -> Bool
$c/= :: LoopMode -> LoopMode -> Bool
== :: LoopMode -> LoopMode -> Bool
$c== :: LoopMode -> LoopMode -> Bool
Eq, Int -> LoopMode
LoopMode -> Int
LoopMode -> [LoopMode]
LoopMode -> LoopMode
LoopMode -> LoopMode -> [LoopMode]
LoopMode -> LoopMode -> LoopMode -> [LoopMode]
(LoopMode -> LoopMode)
-> (LoopMode -> LoopMode)
-> (Int -> LoopMode)
-> (LoopMode -> Int)
-> (LoopMode -> [LoopMode])
-> (LoopMode -> LoopMode -> [LoopMode])
-> (LoopMode -> LoopMode -> [LoopMode])
-> (LoopMode -> LoopMode -> LoopMode -> [LoopMode])
-> Enum LoopMode
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: LoopMode -> LoopMode -> LoopMode -> [LoopMode]
$cenumFromThenTo :: LoopMode -> LoopMode -> LoopMode -> [LoopMode]
enumFromTo :: LoopMode -> LoopMode -> [LoopMode]
$cenumFromTo :: LoopMode -> LoopMode -> [LoopMode]
enumFromThen :: LoopMode -> LoopMode -> [LoopMode]
$cenumFromThen :: LoopMode -> LoopMode -> [LoopMode]
enumFrom :: LoopMode -> [LoopMode]
$cenumFrom :: LoopMode -> [LoopMode]
fromEnum :: LoopMode -> Int
$cfromEnum :: LoopMode -> Int
toEnum :: Int -> LoopMode
$ctoEnum :: Int -> LoopMode
pred :: LoopMode -> LoopMode
$cpred :: LoopMode -> LoopMode
succ :: LoopMode -> LoopMode
$csucc :: LoopMode -> LoopMode
Enum)
ramSnd :: LoopMode -> Sig -> String -> Sig2
ramSnd :: LoopMode -> Sig -> String -> (Sig, Sig)
ramSnd LoopMode
loopMode Sig
speed String
file = Sig -> Sig -> Tab -> (Sig, Sig)
forall a. Tuple a => Sig -> Sig -> Tab -> a
loscil3 Sig
1 Sig
speed Tab
t (Sig, Sig) -> [D] -> (Sig, Sig)
forall a. Tuple a => a -> [D] -> a
`withDs` [D
1, Int -> D
int (Int -> D) -> Int -> D
forall a b. (a -> b) -> a -> b
$ LoopMode -> Int
forall a. Enum a => a -> Int
fromEnum LoopMode
loopMode]
where t :: Tab
t
| String -> Bool
isMp3 String
file = String -> Double -> Mp3Chn -> Tab
mp3s String
file Double
0 Mp3Chn
forall a. Default a => a
def
| Bool
otherwise = String -> Double -> WavChn -> Tab
wavs String
file Double
0 WavChn
forall a. Default a => a
def
ramSnd1 :: LoopMode -> Sig -> String -> Sig
ramSnd1 :: LoopMode -> Sig -> String -> Sig
ramSnd1 LoopMode
loopMode Sig
speed String
file
| String -> Bool
isMp3 String
file = (\(Sig
aleft, Sig
aright) -> Sig
0.5 Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* (Sig
aleft Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
+ Sig
aright)) ((Sig, Sig) -> Sig) -> (Sig, Sig) -> Sig
forall a b. (a -> b) -> a -> b
$ Sig -> Sig -> Tab -> (Sig, Sig)
forall a. Tuple a => Sig -> Sig -> Tab -> a
loscil3 Sig
1 Sig
speed (String -> Double -> Mp3Chn -> Tab
mp3s String
file Double
0 Mp3Chn
forall a. Default a => a
def) (Sig, Sig) -> [D] -> (Sig, Sig)
forall a. Tuple a => a -> [D] -> a
`withDs` [D
1, Int -> D
int (Int -> D) -> Int -> D
forall a b. (a -> b) -> a -> b
$ LoopMode -> Int
forall a. Enum a => a -> Int
fromEnum LoopMode
loopMode]
| Bool
otherwise = Sig -> Sig -> Tab -> Sig
forall a. Tuple a => Sig -> Sig -> Tab -> a
loscil3 Sig
1 Sig
speed (String -> Double -> WavChn -> Tab
wavs String
file Double
0 WavChn
WavLeft) Sig -> [D] -> Sig
forall a. Tuple a => a -> [D] -> a
`withDs` [D
1, Int -> D
int (Int -> D) -> Int -> D
forall a b. (a -> b) -> a -> b
$ LoopMode -> Int
forall a. Enum a => a -> Int
fromEnum LoopMode
loopMode]
data SampleFormat
=
|
|
| UlawSamples
| Int16
| Int32
| Float32
| Uint8
| Int24
| Float64
deriving (SampleFormat -> SampleFormat -> Bool
(SampleFormat -> SampleFormat -> Bool)
-> (SampleFormat -> SampleFormat -> Bool) -> Eq SampleFormat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SampleFormat -> SampleFormat -> Bool
$c/= :: SampleFormat -> SampleFormat -> Bool
== :: SampleFormat -> SampleFormat -> Bool
$c== :: SampleFormat -> SampleFormat -> Bool
Eq, Eq SampleFormat
Eq SampleFormat
-> (SampleFormat -> SampleFormat -> Ordering)
-> (SampleFormat -> SampleFormat -> Bool)
-> (SampleFormat -> SampleFormat -> Bool)
-> (SampleFormat -> SampleFormat -> Bool)
-> (SampleFormat -> SampleFormat -> Bool)
-> (SampleFormat -> SampleFormat -> SampleFormat)
-> (SampleFormat -> SampleFormat -> SampleFormat)
-> Ord SampleFormat
SampleFormat -> SampleFormat -> Bool
SampleFormat -> SampleFormat -> Ordering
SampleFormat -> SampleFormat -> SampleFormat
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SampleFormat -> SampleFormat -> SampleFormat
$cmin :: SampleFormat -> SampleFormat -> SampleFormat
max :: SampleFormat -> SampleFormat -> SampleFormat
$cmax :: SampleFormat -> SampleFormat -> SampleFormat
>= :: SampleFormat -> SampleFormat -> Bool
$c>= :: SampleFormat -> SampleFormat -> Bool
> :: SampleFormat -> SampleFormat -> Bool
$c> :: SampleFormat -> SampleFormat -> Bool
<= :: SampleFormat -> SampleFormat -> Bool
$c<= :: SampleFormat -> SampleFormat -> Bool
< :: SampleFormat -> SampleFormat -> Bool
$c< :: SampleFormat -> SampleFormat -> Bool
compare :: SampleFormat -> SampleFormat -> Ordering
$ccompare :: SampleFormat -> SampleFormat -> Ordering
$cp1Ord :: Eq SampleFormat
Ord, Int -> SampleFormat
SampleFormat -> Int
SampleFormat -> [SampleFormat]
SampleFormat -> SampleFormat
SampleFormat -> SampleFormat -> [SampleFormat]
SampleFormat -> SampleFormat -> SampleFormat -> [SampleFormat]
(SampleFormat -> SampleFormat)
-> (SampleFormat -> SampleFormat)
-> (Int -> SampleFormat)
-> (SampleFormat -> Int)
-> (SampleFormat -> [SampleFormat])
-> (SampleFormat -> SampleFormat -> [SampleFormat])
-> (SampleFormat -> SampleFormat -> [SampleFormat])
-> (SampleFormat -> SampleFormat -> SampleFormat -> [SampleFormat])
-> Enum SampleFormat
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: SampleFormat -> SampleFormat -> SampleFormat -> [SampleFormat]
$cenumFromThenTo :: SampleFormat -> SampleFormat -> SampleFormat -> [SampleFormat]
enumFromTo :: SampleFormat -> SampleFormat -> [SampleFormat]
$cenumFromTo :: SampleFormat -> SampleFormat -> [SampleFormat]
enumFromThen :: SampleFormat -> SampleFormat -> [SampleFormat]
$cenumFromThen :: SampleFormat -> SampleFormat -> [SampleFormat]
enumFrom :: SampleFormat -> [SampleFormat]
$cenumFrom :: SampleFormat -> [SampleFormat]
fromEnum :: SampleFormat -> Int
$cfromEnum :: SampleFormat -> Int
toEnum :: Int -> SampleFormat
$ctoEnum :: Int -> SampleFormat
pred :: SampleFormat -> SampleFormat
$cpred :: SampleFormat -> SampleFormat
succ :: SampleFormat -> SampleFormat
$csucc :: SampleFormat -> SampleFormat
Enum)
writeSigs :: FormatType -> SampleFormat -> String -> [Sig] -> SE ()
writeSigs :: FormatType -> SampleFormat -> String -> [Sig] -> SE ()
writeSigs FormatType
fmt SampleFormat
sample String
file = Str -> D -> [Sig] -> SE ()
fout (String -> Str
text String
file) D
formatToInt
where
formatToInt :: D
formatToInt = Int -> D
int (Int -> D) -> Int -> D
forall a b. (a -> b) -> a -> b
$ FormatType -> Int
formatTypeToInt FormatType
fmt Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
10 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ SampleFormat -> Int
forall a. Enum a => a -> Int
fromEnum SampleFormat
sample
formatTypeToInt :: FormatType -> Int
formatTypeToInt :: FormatType -> Int
formatTypeToInt FormatType
x = case FormatType
x of
FormatType
Wav -> Int
1
FormatType
Aiff -> Int
2
FormatType
Raw -> Int
3
FormatType
Ircam -> Int
4
FormatType
_ -> String -> Int
forall a. HasCallStack => String -> a
error (String -> Int) -> String -> Int
forall a b. (a -> b) -> a -> b
$ String
"Format " String -> ShowS
forall a. [a] -> [a] -> [a]
++ (FormatType -> String
forall a. Show a => a -> String
show FormatType
x) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" is not supported in the writeSnd."
writeWav :: String -> (Sig, Sig) -> SE ()
writeWav :: String -> (Sig, Sig) -> SE ()
writeWav String
file = FormatType -> SampleFormat -> String -> [Sig] -> SE ()
writeSigs FormatType
Wav SampleFormat
Int16 String
file ([Sig] -> SE ()) -> ((Sig, Sig) -> [Sig]) -> (Sig, Sig) -> SE ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \(Sig
a, Sig
b) -> [Sig
a, Sig
b]
dumpWav :: String -> (Sig, Sig) -> SE (Sig, Sig)
dumpWav :: String -> (Sig, Sig) -> SE (Sig, Sig)
dumpWav String
file (Sig, Sig)
asig = String -> (Sig, Sig) -> SE ()
writeWav String
file (Sig, Sig)
asig SE () -> SE (Sig, Sig) -> SE (Sig, Sig)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Sig, Sig) -> SE (Sig, Sig)
forall (m :: * -> *) a. Monad m => a -> m a
return (Sig, Sig)
asig
dumpWav1 :: String -> Sig -> SE Sig
dumpWav1 :: String -> Sig -> SE Sig
dumpWav1 String
file Sig
asig = String -> (Sig, Sig) -> SE ()
writeWav String
file (Sig
asig, Sig
asig) SE () -> SE Sig -> SE Sig
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Sig -> SE Sig
forall (m :: * -> *) a. Monad m => a -> m a
return Sig
asig
writeAiff :: String -> (Sig, Sig) -> SE ()
writeAiff :: String -> (Sig, Sig) -> SE ()
writeAiff String
file = FormatType -> SampleFormat -> String -> [Sig] -> SE ()
writeSigs FormatType
Aiff SampleFormat
Int16 String
file ([Sig] -> SE ()) -> ((Sig, Sig) -> [Sig]) -> (Sig, Sig) -> SE ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \(Sig
a, Sig
b) -> [Sig
a, Sig
b]
writeWav1 :: String -> Sig -> SE ()
writeWav1 :: String -> Sig -> SE ()
writeWav1 String
file = String -> (Sig, Sig) -> SE ()
writeWav String
file ((Sig, Sig) -> SE ()) -> (Sig -> (Sig, Sig)) -> Sig -> SE ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \Sig
x -> (Sig
x, Sig
x)
writeAiff1 :: String -> Sig -> SE ()
writeAiff1 :: String -> Sig -> SE ()
writeAiff1 String
file = String -> (Sig, Sig) -> SE ()
writeAiff String
file ((Sig, Sig) -> SE ()) -> (Sig -> (Sig, Sig)) -> Sig -> SE ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \Sig
x -> (Sig
x, Sig
x)
ramTab :: Fidelity -> Tab -> Sig -> Sig -> Sig
ramTab :: D -> Tab -> Sig -> Sig -> Sig
ramTab D
winSizePowerOfTwo Tab
tab Sig
aptr Sig
pitch = Sig -> Sig -> Sig -> Tab -> Sig -> Sig
mincer Sig
aptr Sig
1 Sig
pitch Tab
tab Sig
1 Sig -> D -> Sig
forall a. Tuple a => a -> D -> a
`withD` (D
2 D -> D -> D
forall a. Floating a => a -> a -> a
** (D
winSizePowerOfTwo D -> D -> D
forall a. Num a => a -> a -> a
+ D
11))
lphase :: D -> Sig -> Sig -> Sig -> Sig
lphase :: D -> Sig -> Sig -> Sig -> Sig
lphase D
irefdur Sig
kloopstart Sig
kloopend Sig
kspeed = Sig
atimpt Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* D -> Sig
sig D
irefdur
where
kfqrel :: Sig
kfqrel = Sig
kspeed Sig -> Sig -> Sig
forall a. Fractional a => a -> a -> a
/ (Sig
kloopend Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
- Sig
kloopstart)
andxrel :: Sig
andxrel = Sig -> Sig
phasor Sig
kfqrel
atimpt :: Sig
atimpt = Sig
andxrel Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* (Sig
kloopendSig -> Sig -> Sig
forall a. Num a => a -> a -> a
-Sig
kloopstart) Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
+ Sig
kloopstart
data Phsr = Phsr
{ Phsr -> String
phsrFile :: String
, Phsr -> Sig
phsrStart :: Sig
, Phsr -> Sig
phsrEnd :: Sig
, Phsr -> Sig
phsrSpeed :: Sig
}
phsrOnce :: Phsr -> Phsr
phsrOnce :: Phsr -> Phsr
phsrOnce Phsr
a = Phsr
a { phsrSpeed :: Sig
phsrSpeed = Phsr -> Sig
phsrSpeed Phsr
a Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* [D] -> Sig
linseg [D
1, D
dt, D
1, D
0.01, D
0] }
where dt :: D
dt = Sig -> D
ir (Sig -> D) -> Sig -> D
forall a b. (a -> b) -> a -> b
$ Sig -> Sig
forall a. Num a => a -> a
abs (Sig -> Sig) -> Sig -> Sig
forall a b. (a -> b) -> a -> b
$ (Phsr -> Sig
phsrEnd Phsr
a Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
- Phsr -> Sig
phsrStart Phsr
a) Sig -> Sig -> Sig
forall a. Fractional a => a -> a -> a
/ Phsr -> Sig
phsrSpeed Phsr
a
phsrBounce :: Phsr -> Phsr
phsrBounce :: Phsr -> Phsr
phsrBounce Phsr
a = Phsr
a { phsrSpeed :: Sig
phsrSpeed = Phsr -> Sig
phsrSpeed Phsr
a Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* Sig -> Sig
sqr (Sig
1 Sig -> Sig -> Sig
forall a. Fractional a => a -> a -> a
/ Sig
dt) }
where dt :: Sig
dt = Sig -> Sig
forall a. Num a => a -> a
abs (Sig -> Sig) -> Sig -> Sig
forall a b. (a -> b) -> a -> b
$ (Phsr -> Sig
phsrEnd Phsr
a Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
- Phsr -> Sig
phsrStart Phsr
a) Sig -> Sig -> Sig
forall a. Fractional a => a -> a -> a
/ Phsr -> Sig
phsrSpeed Phsr
a
relPhsr :: String -> Sig -> Sig -> Sig -> Phsr
relPhsr :: String -> Sig -> Sig -> Sig -> Phsr
relPhsr String
file Sig
start Sig
end Sig
speed = Phsr :: String -> Sig -> Sig -> Sig -> Phsr
Phsr
{ phsrFile :: String
phsrFile = String
file
, phsrStart :: Sig
phsrStart = Sig
start Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* D -> Sig
sig D
len
, phsrEnd :: Sig
phsrEnd = Sig
end Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* D -> Sig
sig D
len
, phsrSpeed :: Sig
phsrSpeed = Sig
speed }
where
len :: D
len = (Str -> D
filelen (Str -> D) -> Str -> D
forall a b. (a -> b) -> a -> b
$ String -> Str
text String
file) D -> D -> D
forall a. Fractional a => a -> a -> a
/ D
srFactor
srFactor :: D
srFactor = D
getSampleRate D -> D -> D
forall a. Fractional a => a -> a -> a
/ Str -> D
filesr (String -> Str
text String
file)
sndPhsr :: String -> Sig -> Phsr
sndPhsr :: String -> Sig -> Phsr
sndPhsr String
file Sig
speed = String -> Sig -> Sig -> Sig -> Phsr
relPhsr String
file Sig
0 Sig
1 Sig
speed
ram1 :: Fidelity -> Phsr -> Sig -> Sig
ram1 :: D -> Phsr -> Sig -> Sig
ram1 = Bool -> Int -> D -> Phsr -> Sig -> Sig
ramChn Bool
True Int
1
ram :: Fidelity -> Phsr -> Sig -> Sig2
ram :: D -> Phsr -> Sig -> (Sig, Sig)
ram D
winSize Phsr
phsr Sig
pitch = (Bool -> Int -> D -> Phsr -> Sig -> Sig
ramChn Bool
False Int
1 D
winSize Phsr
phsr Sig
pitch, Bool -> Int -> D -> Phsr -> Sig -> Sig
ramChn Bool
False Int
2 D
winSize Phsr
phsr Sig
pitch)
ramChn :: Bool -> Int -> Fidelity -> Phsr -> Sig -> Sig
ramChn :: Bool -> Int -> D -> Phsr -> Sig -> Sig
ramChn Bool
isMono Int
n D
winSize (Phsr String
file Sig
start Sig
end Sig
speed) Sig
pitch =
BoolSig -> Sig -> Sig -> Sig
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB (Sig -> Sig
forall a. Num a => a -> a
abs Sig
speed Sig -> Sig -> BooleanOf Sig
forall a. OrdB a => a -> a -> BooleanOf a
`lessThan` Sig
0.001) Sig
0 (Sig -> Sig) -> Sig -> Sig
forall a b. (a -> b) -> a -> b
$
D -> Tab -> Sig -> Sig -> Sig
ramTab D
winSize (Bool -> Int -> String -> Tab
mkTab Bool
isMono Int
n String
file ) (D -> Sig -> Sig -> Sig -> Sig
lphase (Str -> D
filelen (Str -> D) -> Str -> D
forall a b. (a -> b) -> a -> b
$ String -> Str
text String
file) Sig
start Sig
end (Sig
speed Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* Sig
srFactor)) (Sig
pitch Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* Sig
srFactor)
where srFactor :: Sig
srFactor = D -> Sig
sig (D -> Sig) -> D -> Sig
forall a b. (a -> b) -> a -> b
$ (Str -> D
filesr (Str -> D) -> Str -> D
forall a b. (a -> b) -> a -> b
$ String -> Str
text String
file) D -> D -> D
forall a. Fractional a => a -> a -> a
/ D
getSampleRate
mkTab :: Bool -> Int -> String -> Tab
mkTab :: Bool -> Int -> String -> Tab
mkTab Bool
isMono Int
chn String
file
| Bool
mp3 Bool -> Bool -> Bool
&& Bool
isMono = String -> Double -> Mp3Chn -> Tab
mp3s String
file Double
0 Mp3Chn
Mp3Mono
| Bool
mp3 Bool -> Bool -> Bool
&& Bool
isStereo = String -> Double -> Mp3Chn -> Tab
mp3s String
file Double
0 (if Int
chn Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1 then Mp3Chn
Mp3Left else Mp3Chn
Mp3Right)
| Bool
otherwise = String -> Double -> WavChn -> Tab
wavs String
file Double
0 (if Int
chn Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1 then WavChn
WavLeft else WavChn
WavRight)
where
mp3 :: Bool
mp3 = String -> Bool
isMp3 String
file
isStereo :: Bool
isStereo = Bool -> Bool
not Bool
isMono
type Fidelity = D
type TempoSig = Sig
type PitchSig = Sig
readRam :: Fidelity -> TempoSig-> PitchSig -> String -> Sig2
readRam :: D -> Sig -> Sig -> String -> (Sig, Sig)
readRam D
winSize Sig
tempo Sig
pitch String
file = D -> Phsr -> Sig -> (Sig, Sig)
ram D
winSize (Phsr -> Phsr
phsrOnce (Phsr -> Phsr) -> Phsr -> Phsr
forall a b. (a -> b) -> a -> b
$ String -> Sig -> Phsr
sndPhsr String
file Sig
tempo) Sig
pitch
loopRam :: Fidelity -> TempoSig-> PitchSig -> String -> Sig2
loopRam :: D -> Sig -> Sig -> String -> (Sig, Sig)
loopRam D
winSize Sig
tempo Sig
pitch String
file = D -> Phsr -> Sig -> (Sig, Sig)
ram D
winSize (String -> Sig -> Phsr
sndPhsr String
file Sig
tempo) Sig
pitch
readSeg :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig2
readSeg :: D -> (Sig, Sig) -> Sig -> Sig -> String -> (Sig, Sig)
readSeg D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch String
file = D -> Phsr -> Sig -> (Sig, Sig)
ram D
winSize (Phsr -> Phsr
phsrOnce (Phsr -> Phsr) -> Phsr -> Phsr
forall a b. (a -> b) -> a -> b
$ String -> Sig -> Sig -> Sig -> Phsr
Phsr String
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
loopSeg :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig2
loopSeg :: D -> (Sig, Sig) -> Sig -> Sig -> String -> (Sig, Sig)
loopSeg D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch String
file = D -> Phsr -> Sig -> (Sig, Sig)
ram D
winSize (String -> Sig -> Sig -> Sig -> Phsr
Phsr String
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
readRel :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig2
readRel :: D -> (Sig, Sig) -> Sig -> Sig -> String -> (Sig, Sig)
readRel D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch String
file = D -> Phsr -> Sig -> (Sig, Sig)
ram D
winSize (Phsr -> Phsr
phsrOnce (Phsr -> Phsr) -> Phsr -> Phsr
forall a b. (a -> b) -> a -> b
$ String -> Sig -> Sig -> Sig -> Phsr
relPhsr String
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
loopRel :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig2
loopRel :: D -> (Sig, Sig) -> Sig -> Sig -> String -> (Sig, Sig)
loopRel D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch String
file = D -> Phsr -> Sig -> (Sig, Sig)
ram D
winSize (String -> Sig -> Sig -> Sig -> Phsr
relPhsr String
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
readRam1 :: Fidelity -> TempoSig-> PitchSig -> String -> Sig
readRam1 :: D -> Sig -> Sig -> String -> Sig
readRam1 D
winSize Sig
tempo Sig
pitch String
file = D -> Phsr -> Sig -> Sig
ram1 D
winSize (Phsr -> Phsr
phsrOnce (Phsr -> Phsr) -> Phsr -> Phsr
forall a b. (a -> b) -> a -> b
$ String -> Sig -> Phsr
sndPhsr String
file Sig
tempo) Sig
pitch
loopRam1 :: Fidelity -> TempoSig-> PitchSig -> String -> Sig
loopRam1 :: D -> Sig -> Sig -> String -> Sig
loopRam1 D
winSize Sig
tempo Sig
pitch String
file = D -> Phsr -> Sig -> Sig
ram1 D
winSize (String -> Sig -> Phsr
sndPhsr String
file Sig
tempo) Sig
pitch
readSeg1 :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig
readSeg1 :: D -> (Sig, Sig) -> Sig -> Sig -> String -> Sig
readSeg1 D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch String
file = D -> Phsr -> Sig -> Sig
ram1 D
winSize (Phsr -> Phsr
phsrOnce (Phsr -> Phsr) -> Phsr -> Phsr
forall a b. (a -> b) -> a -> b
$ String -> Sig -> Sig -> Sig -> Phsr
Phsr String
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
loopSeg1 :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig
loopSeg1 :: D -> (Sig, Sig) -> Sig -> Sig -> String -> Sig
loopSeg1 D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch String
file = D -> Phsr -> Sig -> Sig
ram1 D
winSize (String -> Sig -> Sig -> Sig -> Phsr
Phsr String
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
readRel1 :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig
readRel1 :: D -> (Sig, Sig) -> Sig -> Sig -> String -> Sig
readRel1 D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch String
file = D -> Phsr -> Sig -> Sig
ram1 D
winSize (Phsr -> Phsr
phsrOnce (Phsr -> Phsr) -> Phsr -> Phsr
forall a b. (a -> b) -> a -> b
$ String -> Sig -> Sig -> Sig -> Phsr
relPhsr String
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
loopRel1 :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig
loopRel1 :: D -> (Sig, Sig) -> Sig -> Sig -> String -> Sig
loopRel1 D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch String
file = D -> Phsr -> Sig -> Sig
ram1 D
winSize (String -> Sig -> Sig -> Sig -> Phsr
relPhsr String
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
scaleDrum :: TempoSig -> PitchSig -> String -> Sig2
scaleDrum :: Sig -> Sig -> String -> (Sig, Sig)
scaleDrum = D -> Sig -> Sig -> String -> (Sig, Sig)
scaleWav (-D
2)
scaleHarm :: TempoSig -> PitchSig -> String -> Sig2
scaleHarm :: Sig -> Sig -> String -> (Sig, Sig)
scaleHarm = D -> Sig -> Sig -> String -> (Sig, Sig)
scaleWav D
0
scaleDrum1 :: TempoSig -> PitchSig -> String -> Sig
scaleDrum1 :: Sig -> Sig -> String -> Sig
scaleDrum1 = D -> Sig -> Sig -> String -> Sig
scaleWav1 (-D
2)
scaleHarm1 :: TempoSig -> PitchSig -> String -> Sig
scaleHarm1 :: Sig -> Sig -> String -> Sig
scaleHarm1 = D -> Sig -> Sig -> String -> Sig
scaleWav1 D
0
scaleWav1 :: Fidelity -> TempoSig -> PitchSig -> String -> Sig
scaleWav1 :: D -> Sig -> Sig -> String -> Sig
scaleWav1 D
winSizePowerOfTwo Sig
tempo Sig
pitch String
filename = Tab -> Sig
go (Tab -> Sig) -> Tab -> Sig
forall a b. (a -> b) -> a -> b
$ if Bool
mp3 then String -> Tab
mp3Left String
filename else String -> Tab
wavLeft String
filename
where
go :: Tab -> Sig
go = D -> Sig -> Sig -> Tab -> Sig
simpleTempoScale D
winSizePowerOfTwo Sig
tempo Sig
pitch
mp3 :: Bool
mp3 = String -> Bool
isMp3 String
filename
scaleWav :: Fidelity -> TempoSig -> PitchSig -> String -> Sig2
scaleWav :: D -> Sig -> Sig -> String -> (Sig, Sig)
scaleWav D
winSizePowerOfTwo Sig
tempo Sig
pitch String
filename = (Tab -> Sig
go (Tab -> Sig) -> Tab -> Sig
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> String -> Tab
mkTab Bool
False Int
0 String
filename, Tab -> Sig
go (Tab -> Sig) -> Tab -> Sig
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> String -> Tab
mkTab Bool
False Int
1 String
filename)
where go :: Tab -> Sig
go = D -> Sig -> Sig -> Tab -> Sig
simpleTempoScale D
winSizePowerOfTwo Sig
tempo Sig
pitch
simpleTempoScale :: D -> Sig -> Sig -> Tab -> Sig
simpleTempoScale :: D -> Sig -> Sig -> Tab -> Sig
simpleTempoScale D
winSizePowerOfTwo Sig
tempo Sig
pitch Tab
t = Sig -> Sig -> Sig -> Tab -> Sig -> Sig
temposcal Sig
tempo Sig
1 Sig
pitch Tab
t Sig
1 Sig -> D -> Sig
forall a. Tuple a => a -> D -> a
`withD` (D
2 D -> D -> D
forall a. Floating a => a -> a -> a
** (D
winSizePowerOfTwo D -> D -> D
forall a. Num a => a -> a -> a
+ D
11))