-- | Using the nodeId, we can get a function that updates the particular node of interest
--   this allows us to do SGD with multiple copies of the same DSPNode in a single Filter
getUpdater :: DSPNodeL -> [Filter -> (Double -> Double) -> Filter]
getUpdater dspNode = let
  updater :: _ -> _ -> Filter -> (Double -> Double) -> Filter
  updater nodeType nodeParam = (\ts f -> fmap (\n -> if nodeId n == nodeId dspNode then n{nodeContent = nodeType $ f nodeParam} else n) ts)
 in 
  case nodeContent dspNode of 
    ID a                   -> [ updater ID a]
    HPF t a                -> [ updater (\newT -> HPF newT a) t
                              , updater (\newA -> HPF t newA) a] 
    LPF t a                -> [ updater (\newT -> LPF newT a) t
                              , updater (\newA -> LPF t newA) a]
    PitchShift t a         -> [ updater (\newT -> PitchShift newT a) t
                              , updater (\newA -> PitchShift t newA) a]
    WhiteNoise a           -> [ updater WhiteNoise a]
    FreeVerb t d a         -> [ updater (\newT -> FreeVerb newT d a) t
                              , updater (\newD -> FreeVerb t newD a) d
                              , updater (\newA -> FreeVerb t d newA) a]
getUpdater :: DSPNodeL -> [Filter -> (Double -> Double) -> Filter]
getUpdater dspNode = let
  updater :: _ -> _ -> Filter -> (Double -> Double) -> Filter
  updater nodeType nodeParam = (\ts f -> fmap (\n -> if nodeId n == nodeId dspNode then n{nodeContent = nodeType $ f nodeParam} else n) ts)
 in 
  case nodeContent dspNode of 
    ID a                   -> [ updater ID a]
    HPF t a                -> [ updater (\newT -> HPF newT a) t
                              , updater (\newA -> HPF t newA) a] 
    LPF t a                -> [ updater (\newT -> LPF newT a) t
                              , updater (\newA -> LPF t newA) a]
    PitchShift t a         -> [ updater (\newT -> PitchShift newT a) t
                              , updater (\newA -> PitchShift t newA) a]
    WhiteNoise a           -> [ updater WhiteNoise a]
    FreeVerb t d a         -> [ updater (\newT -> FreeVerb newT d a) t
                              , updater (\newD -> FreeVerb t newD a) d
                              , updater (\newA -> FreeVerb t d newA) a]
getUpdater dspNode = let
  updater :: _ -> _ -> Filter -> (Double -> Double) -> Filter
  updater nodeType nodeParam = (\ts f -> fmap (\n -> if nodeId n == nodeId dspNode then n{nodeContent = nodeType $ f nodeParam} else n) ts)
 in 
  case nodeContent dspNode of 
    ID a                   -> [ updater ID a]
    HPF t a                -> [ updater (\newT -> HPF newT a) t
                              , updater (\newA -> HPF t newA) a] 
    LPF t a                -> [ updater (\newT -> LPF newT a) t
                              , updater (\newA -> LPF t newA) a]
    PitchShift t a         -> [ updater (\newT -> PitchShift newT a) t
                              , updater (\newA -> PitchShift t newA) a]
    WhiteNoise a           -> [ updater WhiteNoise a]
    FreeVerb t d a         -> [ updater (\newT -> FreeVerb newT d a) t
                              , updater (\newD -> FreeVerb t newD a) d
                              , updater (\newA -> FreeVerb t d newA) a]