{-# LANGUAGE OverloadedStrings #-}

-- | Main entry point to renoise.
--
-- A Haskell API for Renoise.

module Main where

import Renoise
import Sound.OSC

-- | Main entry point.
main :: IO ()
main =
  withTransport
    (openTCP ip 8000)
    (sendBundle (bundle immediately
                        [eval code]))
  where ip = "10.0.1.55"

code =
  "renoise.song().patterns[1]:clear()\n\
  \local pattern = renoise.song().patterns[1]\n\
  \local track = pattern.tracks[1]\n\
  \for j = 1, #track.lines do\n\
  \  local note_column = track.lines[j].note_columns[1]\n\
  \  if false and j % 20 == 0 then\n\
  \    note_column.note_string = \"F-4\"\n\
  \    note_column.volume_value = 126\n\
  \    note_column.instrument_value = 0\n\
  \  elseif false and j % 12 == 0 then\n\
  \    note_column.note_string = \"C-4\"\n\
  \    note_column.volume_value = 126\n\
  \    note_column.instrument_value = 0\n\
  \  end\n\
  \end\n\
  \track = pattern.tracks[2]\n\
  \for j = 1, #track.lines do\n\
  \  local note_column = track.lines[j].note_columns[1]\n\
  \  if false and (j-1) % 16 == 0 then\n\
  \    note_column.note_string = \"E-4\"\n\
  \    note_column.volume_value = 126\n\
  \    note_column.instrument_value = 2  end\n\
  \end\n\
  \track = pattern.tracks[3]\n\
  \for j = 1, #track.lines do\n\
  \  local note_column = track.lines[j].note_columns[1]\n\
  \  if false and j % 32 == 0 then\n\
  \    note_column.note_string = \"E-4\"\n\
  \    note_column.volume_value = 126\n\
  \    note_column.instrument_value = 3\n\
  \  else\n\
  \    note_column.note_value = 121\n\
  \  end\n\
  \end\n\
  \track = pattern.tracks[4]\n\
  \for j = 1, #track.lines do\n\
  \  local note_column = track.lines[j].note_columns[1]\n\
  \  if false and  j %  == 0 then\n\
  \    note_column.note_value = j % 50\n\
  \    note_column.volume_value = 126\n\
  \    note_column.instrument_value = 4\n\
  \  elseif true then\n\
  \    note_column.note_value = 120\n\
  \  end\n\
  \end\n\
  \"
