-- e_soundFunction :: Entity
-- e_soundFunction = prim2 "soundFunction" (\d f -> fromFunction 16 d Nothing f)

e_soundFunction :: Entity
e_soundFunction = Entity "soundFunction" (TReal ->> (TReal ->> TReal) ->> TSound) defaultFixity $
  VFun $ \(VReal (RReal d)) ->
    VFun $ \(VFun f) ->
      VSound $ RSound $
        fromFunction 44100 d Nothing $ \t ->
          case fromValue . f . toValue . toPrimitive $ t of
            Nothing -> undefined
            Just x -> monoSample $ fromPrimitive x

-- Requires Strings...
-- e_soundFile :: Entity
-- e_soundFile = Entity "soundFile"

-- Generate list of all primitives


e_soundFunction :: Entity
e_soundFunction = Entity "soundFunction" (TReal ->> (TReal ->> TReal) ->> TSound) defaultFixity $
  VFun $ \(VReal (RReal d)) ->
    VFun $ \(VFun f) ->
      VSound $ RSound $
        fromFunction 44100 d Nothing $ \t ->
          case fromValue . f . toValue . toPrimitive $ t of
            Nothing -> undefined
            Just x -> monoSample $ fromPrimitive x

-- Requires Strings...
-- e_soundFile :: Entity
-- e_soundFile = Entity "soundFile"

-- Generate list of all primitives


e_soundFunction = Entity "soundFunction" (TReal ->> (TReal ->> TReal) ->> TSound) defaultFixity $
  VFun $ \(VReal (RReal d)) ->
    VFun $ \(VFun f) ->
      VSound $ RSound $
        fromFunction 44100 d Nothing $ \t ->
          case fromValue . f . toValue . toPrimitive $ t of
            Nothing -> undefined
            Just x -> monoSample $ fromPrimitive x

-- Requires Strings...
-- e_soundFile :: Entity
-- e_soundFile = Entity "soundFile"

-- Generate list of all primitives

