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 :: forall a. Sigs a => 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 a. 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 :: forall a. Sigs a => 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 :: forall a. Sigs a => 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 a. 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 a b. (a -> b) -> Evt a -> Evt b
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 :: forall a. Sigs a => 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 a. 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 :: forall b. (Num b, Sigs b) => 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 :: forall a. (Num a, Sigs a) => Sig -> [a] -> a
lineSnd Sig
dt [a]
xs = (a -> a -> a) -> [a] -> a
forall a. (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 :: forall a. (Num a, Sigs a) => 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 a. [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 :: [Char] -> Bool
isMp3 [Char]
name = [Char]
".mp3" [Char] -> [Char] -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isSuffixOf` [Char]
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 :: [Char] -> D
lengthSnd [Char]
fileName
| [Char] -> Bool
isMp3 [Char]
fileName = Str -> D
mp3len (Str -> D) -> Str -> D
forall a b. (a -> b) -> a -> b
$ [Char] -> Str
text [Char]
fileName
| Bool
otherwise = Str -> D
filelen (Str -> D) -> Str -> D
forall a b. (a -> b) -> a -> b
$ [Char] -> Str
text [Char]
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 :: [Char] -> (Sig, Sig)
readSnd [Char]
fileName
| [Char] -> Bool
isMp3 [Char]
fileName = Str -> (Sig, Sig)
mp3in ([Char] -> Str
text [Char]
fileName)
| Bool
otherwise = Str -> (Sig, Sig)
forall a. Tuple a => Str -> a
diskin2 ([Char] -> Str
text [Char]
fileName)
loopSndBy :: Sig -> String -> (Sig, Sig)
loopSndBy :: Sig -> [Char] -> (Sig, Sig)
loopSndBy Sig
dt [Char]
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
$ [Char] -> (Sig, Sig)
readSnd [Char]
fileName
loopSnd :: String -> (Sig, Sig)
loopSnd :: [Char] -> (Sig, Sig)
loopSnd [Char]
fileName = Sig -> [Char] -> (Sig, Sig)
loopSndBy (D -> Sig
sig (D -> Sig) -> D -> Sig
forall a b. (a -> b) -> a -> b
$ [Char] -> D
lengthSnd [Char]
fileName) [Char]
fileName
readWav :: Sig -> String -> (Sig, Sig)
readWav :: Sig -> [Char] -> (Sig, Sig)
readWav Sig
speed [Char]
fileName = Str -> (Sig, Sig)
forall a. Tuple a => Str -> a
diskin2 ([Char] -> Str
text [Char]
fileName) (Sig, Sig) -> Sig -> (Sig, Sig)
forall a. Tuple a => a -> Sig -> a
`withSig` Sig
speed
loopWav :: Sig -> String -> (Sig, Sig)
loopWav :: Sig -> [Char] -> (Sig, Sig)
loopWav Sig
speed [Char]
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 ([Char] -> Str
text [Char]
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 -> [Char] -> (Sig, Sig)
readSegWav D
start D
end Sig
speed [Char]
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 ([Char] -> Str
text [Char]
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 -> [Char] -> (Sig, Sig)
tempoReadWav Sig
speed [Char]
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 ([Char] -> Str
text [Char]
fileName) (Sig, Sig) -> Sig -> (Sig, Sig)
forall a. Tuple a => a -> Sig -> a
`withSig` Sig
speed
tempoLoopWav :: Sig -> String -> (Sig, Sig)
tempoLoopWav :: Sig -> [Char] -> (Sig, Sig)
tempoLoopWav Sig
speed [Char]
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 ([Char] -> Str
text [Char]
fileName) (Sig, Sig) -> Sig -> (Sig, Sig)
forall a. Tuple a => a -> Sig -> a
`withSig` Sig
speed
readSnd1 :: String -> Sig
readSnd1 :: [Char] -> Sig
readSnd1 [Char]
fileName
| [Char] -> Bool
isMp3 [Char]
fileName = (Sig, Sig) -> Sig
toMono ((Sig, Sig) -> Sig) -> (Sig, Sig) -> Sig
forall a b. (a -> b) -> a -> b
$ [Char] -> (Sig, Sig)
readSnd [Char]
fileName
| Bool
otherwise = Str -> Sig
forall a. Tuple a => Str -> a
diskin2 ([Char] -> Str
text [Char]
fileName)
loopSndBy1 :: Sig -> String -> Sig
loopSndBy1 :: Sig -> [Char] -> Sig
loopSndBy1 Sig
dt [Char]
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
$ [Char] -> Sig
readSnd1 [Char]
fileName
loopSnd1 :: String -> Sig
loopSnd1 :: [Char] -> Sig
loopSnd1 [Char]
fileName = Sig -> [Char] -> Sig
loopSndBy1 (D -> Sig
sig (D -> Sig) -> D -> Sig
forall a b. (a -> b) -> a -> b
$ [Char] -> D
lengthSnd [Char]
fileName) [Char]
fileName
readWav1 :: Sig -> String -> Sig
readWav1 :: Sig -> [Char] -> Sig
readWav1 Sig
speed [Char]
fileName = Str -> Sig
forall a. Tuple a => Str -> a
diskin2 ([Char] -> Str
text [Char]
fileName) Sig -> Sig -> Sig
forall a. Tuple a => a -> Sig -> a
`withSig` Sig
speed
loopWav1 :: Sig -> String -> Sig
loopWav1 :: Sig -> [Char] -> Sig
loopWav1 Sig
speed [Char]
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 ([Char] -> Str
text [Char]
fileName) Sig -> Sig -> Sig
forall a. Tuple a => a -> Sig -> a
`withSig` Sig
speed
readSegWav1 :: D -> D -> Sig -> String -> Sig
readSegWav1 :: D -> D -> Sig -> [Char] -> Sig
readSegWav1 D
start D
end Sig
speed [Char]
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 ([Char] -> Str
text [Char]
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 -> [Char] -> Sig
tempoReadWav1 Sig
speed [Char]
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 -> [Char] -> Sig
readWav1 Sig
speed [Char]
fileName
tempoLoopWav1 :: Sig -> String -> Sig
tempoLoopWav1 :: Sig -> [Char] -> Sig
tempoLoopWav1 Sig
speed [Char]
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 -> [Char] -> Sig
loopWav1 Sig
speed [Char]
fileName
data LoopMode = Once | Loop | Bounce
deriving (Int -> LoopMode -> ShowS
[LoopMode] -> ShowS
LoopMode -> [Char]
(Int -> LoopMode -> ShowS)
-> (LoopMode -> [Char]) -> ([LoopMode] -> ShowS) -> Show LoopMode
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LoopMode -> ShowS
showsPrec :: Int -> LoopMode -> ShowS
$cshow :: LoopMode -> [Char]
show :: LoopMode -> [Char]
$cshowList :: [LoopMode] -> ShowS
showList :: [LoopMode] -> ShowS
Show, LoopMode -> LoopMode -> Bool
(LoopMode -> LoopMode -> Bool)
-> (LoopMode -> LoopMode -> Bool) -> Eq LoopMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LoopMode -> LoopMode -> Bool
== :: LoopMode -> LoopMode -> Bool
$c/= :: LoopMode -> LoopMode -> Bool
/= :: 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
$csucc :: LoopMode -> LoopMode
succ :: LoopMode -> LoopMode
$cpred :: LoopMode -> LoopMode
pred :: LoopMode -> LoopMode
$ctoEnum :: Int -> LoopMode
toEnum :: Int -> LoopMode
$cfromEnum :: LoopMode -> Int
fromEnum :: LoopMode -> Int
$cenumFrom :: LoopMode -> [LoopMode]
enumFrom :: LoopMode -> [LoopMode]
$cenumFromThen :: LoopMode -> LoopMode -> [LoopMode]
enumFromThen :: LoopMode -> LoopMode -> [LoopMode]
$cenumFromTo :: LoopMode -> LoopMode -> [LoopMode]
enumFromTo :: LoopMode -> LoopMode -> [LoopMode]
$cenumFromThenTo :: LoopMode -> LoopMode -> LoopMode -> [LoopMode]
enumFromThenTo :: LoopMode -> LoopMode -> LoopMode -> [LoopMode]
Enum)
ramSnd :: LoopMode -> Sig -> String -> Sig2
ramSnd :: LoopMode -> Sig -> [Char] -> (Sig, Sig)
ramSnd LoopMode
loopMode Sig
speed [Char]
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
| [Char] -> Bool
isMp3 [Char]
file = [Char] -> Double -> Mp3Chn -> Tab
mp3s [Char]
file Double
0 Mp3Chn
forall a. Default a => a
def
| Bool
otherwise = [Char] -> Double -> WavChn -> Tab
wavs [Char]
file Double
0 WavChn
forall a. Default a => a
def
ramSnd1 :: LoopMode -> Sig -> String -> Sig
ramSnd1 :: LoopMode -> Sig -> [Char] -> Sig
ramSnd1 LoopMode
loopMode Sig
speed [Char]
file
| [Char] -> Bool
isMp3 [Char]
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 ([Char] -> Double -> Mp3Chn -> Tab
mp3s [Char]
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 ([Char] -> Double -> WavChn -> Tab
wavs [Char]
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
$c== :: SampleFormat -> SampleFormat -> Bool
== :: SampleFormat -> SampleFormat -> Bool
$c/= :: SampleFormat -> SampleFormat -> Bool
/= :: 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
$ccompare :: SampleFormat -> SampleFormat -> Ordering
compare :: SampleFormat -> SampleFormat -> Ordering
$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
>= :: SampleFormat -> SampleFormat -> Bool
$cmax :: SampleFormat -> SampleFormat -> SampleFormat
max :: SampleFormat -> SampleFormat -> SampleFormat
$cmin :: SampleFormat -> SampleFormat -> SampleFormat
min :: SampleFormat -> SampleFormat -> 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
$csucc :: SampleFormat -> SampleFormat
succ :: SampleFormat -> SampleFormat
$cpred :: SampleFormat -> SampleFormat
pred :: SampleFormat -> SampleFormat
$ctoEnum :: Int -> SampleFormat
toEnum :: Int -> SampleFormat
$cfromEnum :: SampleFormat -> Int
fromEnum :: SampleFormat -> Int
$cenumFrom :: SampleFormat -> [SampleFormat]
enumFrom :: SampleFormat -> [SampleFormat]
$cenumFromThen :: SampleFormat -> SampleFormat -> [SampleFormat]
enumFromThen :: SampleFormat -> SampleFormat -> [SampleFormat]
$cenumFromTo :: SampleFormat -> SampleFormat -> [SampleFormat]
enumFromTo :: SampleFormat -> SampleFormat -> [SampleFormat]
$cenumFromThenTo :: SampleFormat -> SampleFormat -> SampleFormat -> [SampleFormat]
enumFromThenTo :: SampleFormat -> SampleFormat -> SampleFormat -> [SampleFormat]
Enum)
writeSigs :: FormatType -> SampleFormat -> String -> [Sig] -> SE ()
writeSigs :: FormatType -> SampleFormat -> [Char] -> [Sig] -> SE ()
writeSigs FormatType
fmt SampleFormat
sample [Char]
file = Str -> D -> [Sig] -> SE ()
fout ([Char] -> Str
text [Char]
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
_ -> [Char] -> Int
forall a. HasCallStack => [Char] -> a
error ([Char] -> Int) -> [Char] -> Int
forall a b. (a -> b) -> a -> b
$ [Char]
"Format " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ (FormatType -> [Char]
forall a. Show a => a -> [Char]
show FormatType
x) [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char]
" is not supported in the writeSnd."
writeWav :: String -> (Sig, Sig) -> SE ()
writeWav :: [Char] -> (Sig, Sig) -> SE ()
writeWav [Char]
file = FormatType -> SampleFormat -> [Char] -> [Sig] -> SE ()
writeSigs FormatType
Wav SampleFormat
Int16 [Char]
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 :: [Char] -> (Sig, Sig) -> SE (Sig, Sig)
dumpWav [Char]
file (Sig, Sig)
asig = [Char] -> (Sig, Sig) -> SE ()
writeWav [Char]
file (Sig, Sig)
asig SE () -> SE (Sig, Sig) -> SE (Sig, Sig)
forall a b. SE a -> SE b -> SE b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Sig, Sig) -> SE (Sig, Sig)
forall a. a -> SE a
forall (m :: * -> *) a. Monad m => a -> m a
return (Sig, Sig)
asig
dumpWav1 :: String -> Sig -> SE Sig
dumpWav1 :: [Char] -> Sig -> SE Sig
dumpWav1 [Char]
file Sig
asig = [Char] -> (Sig, Sig) -> SE ()
writeWav [Char]
file (Sig
asig, Sig
asig) SE () -> SE Sig -> SE Sig
forall a b. SE a -> SE b -> SE b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Sig -> SE Sig
forall a. a -> SE a
forall (m :: * -> *) a. Monad m => a -> m a
return Sig
asig
writeAiff :: String -> (Sig, Sig) -> SE ()
writeAiff :: [Char] -> (Sig, Sig) -> SE ()
writeAiff [Char]
file = FormatType -> SampleFormat -> [Char] -> [Sig] -> SE ()
writeSigs FormatType
Aiff SampleFormat
Int16 [Char]
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 :: [Char] -> Sig -> SE ()
writeWav1 [Char]
file = [Char] -> (Sig, Sig) -> SE ()
writeWav [Char]
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 :: [Char] -> Sig -> SE ()
writeAiff1 [Char]
file = [Char] -> (Sig, Sig) -> SE ()
writeAiff [Char]
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 -> [Char]
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 = phsrSpeed a * linseg [1, dt, 1, 0.01, 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 = phsrSpeed a * sqr (1 / 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 :: [Char] -> Sig -> Sig -> Sig -> Phsr
relPhsr [Char]
file Sig
start Sig
end Sig
speed = Phsr
{ phsrFile :: [Char]
phsrFile = [Char]
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
$ [Char] -> Str
text [Char]
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 ([Char] -> Str
text [Char]
file)
sndPhsr :: String -> Sig -> Phsr
sndPhsr :: [Char] -> Sig -> Phsr
sndPhsr [Char]
file Sig
speed = [Char] -> Sig -> Sig -> Sig -> Phsr
relPhsr [Char]
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 [Char]
file Sig
start Sig
end Sig
speed) Sig
pitch =
BoolSig -> Sig -> Sig -> Sig
forall bool. (bool ~ BooleanOf Sig) => bool -> 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 -> [Char] -> Tab
mkTab Bool
isMono Int
n [Char]
file ) (D -> Sig -> Sig -> Sig -> Sig
lphase (Str -> D
filelen (Str -> D) -> Str -> D
forall a b. (a -> b) -> a -> b
$ [Char] -> Str
text [Char]
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
$ [Char] -> Str
text [Char]
file) D -> D -> D
forall a. Fractional a => a -> a -> a
/ D
getSampleRate
mkTab :: Bool -> Int -> String -> Tab
mkTab :: Bool -> Int -> [Char] -> Tab
mkTab Bool
isMono Int
chn [Char]
file
| Bool
mp3 Bool -> Bool -> Bool
&& Bool
isMono = [Char] -> Double -> Mp3Chn -> Tab
mp3s [Char]
file Double
0 Mp3Chn
Mp3Mono
| Bool
mp3 Bool -> Bool -> Bool
&& Bool
isStereo = [Char] -> Double -> Mp3Chn -> Tab
mp3s [Char]
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 = [Char] -> Double -> WavChn -> Tab
wavs [Char]
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 = [Char] -> Bool
isMp3 [Char]
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 -> [Char] -> (Sig, Sig)
readRam D
winSize Sig
tempo Sig
pitch [Char]
file = D -> Phsr -> Sig -> (Sig, Sig)
ram D
winSize (Phsr -> Phsr
phsrOnce (Phsr -> Phsr) -> Phsr -> Phsr
forall a b. (a -> b) -> a -> b
$ [Char] -> Sig -> Phsr
sndPhsr [Char]
file Sig
tempo) Sig
pitch
loopRam :: Fidelity -> TempoSig-> PitchSig -> String -> Sig2
loopRam :: D -> Sig -> Sig -> [Char] -> (Sig, Sig)
loopRam D
winSize Sig
tempo Sig
pitch [Char]
file = D -> Phsr -> Sig -> (Sig, Sig)
ram D
winSize ([Char] -> Sig -> Phsr
sndPhsr [Char]
file Sig
tempo) Sig
pitch
readSeg :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig2
readSeg :: D -> (Sig, Sig) -> Sig -> Sig -> [Char] -> (Sig, Sig)
readSeg D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch [Char]
file = D -> Phsr -> Sig -> (Sig, Sig)
ram D
winSize (Phsr -> Phsr
phsrOnce (Phsr -> Phsr) -> Phsr -> Phsr
forall a b. (a -> b) -> a -> b
$ [Char] -> Sig -> Sig -> Sig -> Phsr
Phsr [Char]
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
loopSeg :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig2
loopSeg :: D -> (Sig, Sig) -> Sig -> Sig -> [Char] -> (Sig, Sig)
loopSeg D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch [Char]
file = D -> Phsr -> Sig -> (Sig, Sig)
ram D
winSize ([Char] -> Sig -> Sig -> Sig -> Phsr
Phsr [Char]
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
readRel :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig2
readRel :: D -> (Sig, Sig) -> Sig -> Sig -> [Char] -> (Sig, Sig)
readRel D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch [Char]
file = D -> Phsr -> Sig -> (Sig, Sig)
ram D
winSize (Phsr -> Phsr
phsrOnce (Phsr -> Phsr) -> Phsr -> Phsr
forall a b. (a -> b) -> a -> b
$ [Char] -> Sig -> Sig -> Sig -> Phsr
relPhsr [Char]
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
loopRel :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig2
loopRel :: D -> (Sig, Sig) -> Sig -> Sig -> [Char] -> (Sig, Sig)
loopRel D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch [Char]
file = D -> Phsr -> Sig -> (Sig, Sig)
ram D
winSize ([Char] -> Sig -> Sig -> Sig -> Phsr
relPhsr [Char]
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
readRam1 :: Fidelity -> TempoSig-> PitchSig -> String -> Sig
readRam1 :: D -> Sig -> Sig -> [Char] -> Sig
readRam1 D
winSize Sig
tempo Sig
pitch [Char]
file = D -> Phsr -> Sig -> Sig
ram1 D
winSize (Phsr -> Phsr
phsrOnce (Phsr -> Phsr) -> Phsr -> Phsr
forall a b. (a -> b) -> a -> b
$ [Char] -> Sig -> Phsr
sndPhsr [Char]
file Sig
tempo) Sig
pitch
loopRam1 :: Fidelity -> TempoSig-> PitchSig -> String -> Sig
loopRam1 :: D -> Sig -> Sig -> [Char] -> Sig
loopRam1 D
winSize Sig
tempo Sig
pitch [Char]
file = D -> Phsr -> Sig -> Sig
ram1 D
winSize ([Char] -> Sig -> Phsr
sndPhsr [Char]
file Sig
tempo) Sig
pitch
readSeg1 :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig
readSeg1 :: D -> (Sig, Sig) -> Sig -> Sig -> [Char] -> Sig
readSeg1 D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch [Char]
file = D -> Phsr -> Sig -> Sig
ram1 D
winSize (Phsr -> Phsr
phsrOnce (Phsr -> Phsr) -> Phsr -> Phsr
forall a b. (a -> b) -> a -> b
$ [Char] -> Sig -> Sig -> Sig -> Phsr
Phsr [Char]
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
loopSeg1 :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig
loopSeg1 :: D -> (Sig, Sig) -> Sig -> Sig -> [Char] -> Sig
loopSeg1 D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch [Char]
file = D -> Phsr -> Sig -> Sig
ram1 D
winSize ([Char] -> Sig -> Sig -> Sig -> Phsr
Phsr [Char]
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
readRel1 :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig
readRel1 :: D -> (Sig, Sig) -> Sig -> Sig -> [Char] -> Sig
readRel1 D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch [Char]
file = D -> Phsr -> Sig -> Sig
ram1 D
winSize (Phsr -> Phsr
phsrOnce (Phsr -> Phsr) -> Phsr -> Phsr
forall a b. (a -> b) -> a -> b
$ [Char] -> Sig -> Sig -> Sig -> Phsr
relPhsr [Char]
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
loopRel1 :: Fidelity -> (Sig, Sig) -> TempoSig-> PitchSig -> String -> Sig
loopRel1 :: D -> (Sig, Sig) -> Sig -> Sig -> [Char] -> Sig
loopRel1 D
winSize (Sig
kmin, Sig
kmax) Sig
tempo Sig
pitch [Char]
file = D -> Phsr -> Sig -> Sig
ram1 D
winSize ([Char] -> Sig -> Sig -> Sig -> Phsr
relPhsr [Char]
file Sig
kmin Sig
kmax Sig
tempo) Sig
pitch
scaleDrum :: TempoSig -> PitchSig -> String -> Sig2
scaleDrum :: Sig -> Sig -> [Char] -> (Sig, Sig)
scaleDrum = D -> Sig -> Sig -> [Char] -> (Sig, Sig)
scaleWav (-D
2)
scaleHarm :: TempoSig -> PitchSig -> String -> Sig2
scaleHarm :: Sig -> Sig -> [Char] -> (Sig, Sig)
scaleHarm = D -> Sig -> Sig -> [Char] -> (Sig, Sig)
scaleWav D
0
scaleDrum1 :: TempoSig -> PitchSig -> String -> Sig
scaleDrum1 :: Sig -> Sig -> [Char] -> Sig
scaleDrum1 = D -> Sig -> Sig -> [Char] -> Sig
scaleWav1 (-D
2)
scaleHarm1 :: TempoSig -> PitchSig -> String -> Sig
scaleHarm1 :: Sig -> Sig -> [Char] -> Sig
scaleHarm1 = D -> Sig -> Sig -> [Char] -> Sig
scaleWav1 D
0
scaleWav1 :: Fidelity -> TempoSig -> PitchSig -> String -> Sig
scaleWav1 :: D -> Sig -> Sig -> [Char] -> Sig
scaleWav1 D
winSizePowerOfTwo Sig
tempo Sig
pitch [Char]
filename = Tab -> Sig
go (Tab -> Sig) -> Tab -> Sig
forall a b. (a -> b) -> a -> b
$ if Bool
mp3 then [Char] -> Tab
mp3Left [Char]
filename else [Char] -> Tab
wavLeft [Char]
filename
where
go :: Tab -> Sig
go = D -> Sig -> Sig -> Tab -> Sig
simpleTempoScale D
winSizePowerOfTwo Sig
tempo Sig
pitch
mp3 :: Bool
mp3 = [Char] -> Bool
isMp3 [Char]
filename
scaleWav :: Fidelity -> TempoSig -> PitchSig -> String -> Sig2
scaleWav :: D -> Sig -> Sig -> [Char] -> (Sig, Sig)
scaleWav D
winSizePowerOfTwo Sig
tempo Sig
pitch [Char]
filename = (Tab -> Sig
go (Tab -> Sig) -> Tab -> Sig
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> [Char] -> Tab
mkTab Bool
False Int
0 [Char]
filename, Tab -> Sig
go (Tab -> Sig) -> Tab -> Sig
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> [Char] -> Tab
mkTab Bool
False Int
1 [Char]
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))