module Samples where import Types (sampleRate, Oscillator, SampledSignal, Semitone) oscFromSample :: Semitone -> SampledSignal -> Oscillator oscFromSample baseSemitone ss = sampleOsc where sampleCount = length ss sampleOsc st duration t | sampleIndex < 0 || sampleIndex >= sampleCount = 0 | otherwise = ss !! sampleIndex where sampleIndex = round (t * sampleRate) -- realPiano :: Oscillator -- realPiano = oscFromSample 3 pianoSampleC4 realPiano = undefined readSample :: String -> IO SampledSignal readSample fName = do fContent <- readFile fName return $ map read $ lines fContent