From 615a27ddbe01eb2968d24e47cbaef7d73b243e0b Mon Sep 17 00:00:00 2001 From: Paul-Louis NECH <pln@algolia.com> Date: Sun, 4 May 2025 15:52:00 +0200 Subject: [PATCH] feat: DPV working! --- BootTidal.hs | 42 ++++++++++++++++++++++++++++++++++++++---- didacticpatternvisualizer.pde | 44 ++++++++++++++++++++++++++++++++++++++++++++ utils/dpv.tidal | 13 +++++++++++++ 3 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 didacticpatternvisualizer.pde create mode 100644 utils/dpv.tidal diff --git a/BootTidal.hs b/BootTidal.hs index c42dc49..82266b4 100644 --- a/BootTidal.hs +++ b/BootTidal.hs @@ -2,13 +2,36 @@ :set prompt "" import Sound.Tidal.Context - import System.IO (hSetEncoding, stdout, utf8) hSetEncoding stdout utf8 --- total latency = oLatency + cFrameTimespan -tidal <- startTidal (superdirtTarget {oLatency = 0.2, oAddress = "127.0.0.1", oPort = 57120}) (defaultConfig {cFrameTimespan = 1/20}) +-- DPV setup +:{ +let targetdpv = Target {oName = "didacticpatternvisualizer", + oAddress = "127.0.0.1", + oPort = 1818, + oLatency = 0.2, + oWindow = Nothing, + oSchedule = Live, + oBusPort = Nothing, + oHandshake = False + } + formatsdpv = [OSC "/delivery" Named {requiredArgs = []} ] +:} +-- SuperDirt target +:{ +let superdirtTarget' = superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120} +:} +:{ +-- Set up targets for both SuperDirt and DPV +let oscmapdpv = [(targetdpv, formatsdpv), + (superdirtTarget', [superdirtShape]) + ] +:} +-- Initialize TidalCycles with both targets +tidal <- startStream defaultConfig {cFrameTimespan = 1/20} oscmapdpv + :{ let p = streamReplace tidal @@ -69,7 +92,18 @@ let setI = streamSetI tidal :} :{ -let modIndex = pF "modIndex" +let -- DPV specific parameters + grid = pS "grid" + connectionN = pI "connectionN" + connectionMax = pI "connectionMax" + speedSequenser = pF "speedSequenser" + clear = pI "clear" + sizeMin = pF "sizeMin" + sizeMax = pF "sizeMax" + figure = pS "figure" + color = pS "color" + -- Other parameters + modIndex = pF "modIndex" mix = pF "mix" vibrato = pF "vibrato" chorus = pF "chorus" diff --git a/didacticpatternvisualizer.pde b/didacticpatternvisualizer.pde new file mode 100644 index 0000000..ded1a8d --- /dev/null +++ b/didacticpatternvisualizer.pde @@ -0,0 +1,44 @@ +import oscP5.*; +import netP5.*; + +OscP5 osc; + +ArrayList<Sound> sounds = new ArrayList<Sound>(); +ArrayList<Cycle> cycles = new ArrayList<Cycle>(); + +float alturaBar; +float offsetSubdivision = 40; + +int connectionTotal = 4; // set total tracks (Number of Tidal connections to represent) +float movSequenser= 2; // set grid speed (higher speed makes time wider) + + +void setup() { + osc = new OscP5(this, 1818); + size(1280,360); + //fullScreen(P3D, 2); + alturaBar = height/connectionTotal; + noStroke(); + fill(0); + textSize(18); +} + + + +void draw() { + background(0); + fill(255); + rectMode(CORNER); + rect(0,0,width,height); + fill(228); + noStroke(); + for(int y=0; y<(connectionTotal*0.5); y++ ) { + rect(0, y*alturaBar*2, width, alturaBar); + } + for(int i=0; i<sounds.size() ; i++) { + if ( sounds.get(i)!= null) { sounds.get(i).draw(); } + } + for(int i=0; i<cycles.size() ; i++) { + if ( cycles.get(i)!= null) { cycles.get(i).draw(); } + } +} diff --git a/utils/dpv.tidal b/utils/dpv.tidal new file mode 100644 index 0000000..7d1d363 --- /dev/null +++ b/utils/dpv.tidal @@ -0,0 +1,13 @@ +-- EX1 Initialize DPV with 2 connections at speed 4 +do asap $ connectionMax 2 # speedSequenser 4 + d5 $ grid "1 0!7" -- Set grid pattern + -- Play a pattern with visualization + d1 $ s "bd(3,8)" # connectionN 1 + d2 $ s "hh(6,8)" # connectionN 2 + + +-- EX2 Initialize DPV +do asap $ connectionMax 3 # speedSequenser 4 + d5 $ grid "1 0!15" +-- Play a pattern with visualization + d1 $ s "bd(3,8)" # connectionN 1 # sizeMin 12 # sizeMax 60 # figure "rect" # color "0519f5" -- libgit2 0.27.0