reduzent / netpd-instruments

instruments (synths, sequencers, utilities, etc) to be used with netpd
http://www.netpd.org
20 stars 4 forks source link

qseq3: restoring from preset broken #50

Closed reduzent closed 1 year ago

reduzent commented 1 year ago

State syncing from peer works OK, but when restoring from preset, too many sets appear, or wrong assignment of instruments to sequences.

reduzent commented 1 year ago

In more detail for later reference:

When loading the preset 2022-06-14_tr808-beat2.pst, sometimes two sets appeared (the second empty). Sometimes the sequences in set 1 where duplicated. Sometimes, wrong instrument names were assigned to sequences, or wrong sequence lengths. Sometimes some errors like 2.1.10.16.r: no such object were printed to the console. When two instances of netpd were open, the errors appeared sometimes on one instance, but not on the other. Also, the errors happened only when loading from preset file, but never while syncing between peers.

Also, the output of debug to on and debug from on looked sane and didn't show any indication of another set or additional sequences. So the problem seems internal to qseq3 and not related to state saving. Once a wrong state was established in a netpd client, it would transfer the wrong state to other peers.

reduzent commented 1 year ago

Debug log of debug to on and debug from on when loading that preset:

NETPD_SND: [..b] /unpatch/preset/load/start
NETPD_SND: [..b] /unpatch/netcloseall
NETPD_SND: [..b] /unpatch/netload 1 master
NETPD_SND: [..b] /unpatch/netload 2 qseq3
NETPD_SND: [..b] /unpatch/netload 3 tr808
NETPD_SND: [..b] /unpatch/synced
NETPD_SND: [..b] /1/master/bpm 110.762
NETPD_SND: [..b] /1/master/shuffle 54.1353
NETPD_SND: [..b] /1/master/mode 1
NETPD_SND: [..b] /1/master/startstop 1
NETPD_SND: [..b] /1/master/step 88.2656
NETPD_SND: [..b] /1/master/dump/finished
NETPD_SND: [..b] /2/qseq3/set/create 1
NETPD_SND: [..b] /2/qseq3/seq/create 1 16 3-tr808 bassdrum 4
NETPD_SND: [..b] /2/qseq3/seq/create 1 16 3-tr808 snare 4
NETPD_SND: [..b] /2/qseq3/seq/create 1 16 3-tr808 clap 4
NETPD_SND: [..b] /2/qseq3/seq/create 1 16 3-tr808 rimshot 4
NETPD_SND: [..b] /2/qseq3/seq/create 1 16 3-tr808 ohihat 4
NETPD_SND: [..b] /2/qseq3/seq/create 1 16 3-tr808 chihat 4
NETPD_SND: [..b] /2/qseq3/seq/create 1 16 3-tr808 cymbal 4
NETPD_SND: [..b] /2/qseq3/seq/create 1 16 3-tr808 bell 4
NETPD_SND: [..b] /2/qseq3/seq/create 1 32 3-tr808 cymbal 4
NETPD_SND: [..b] /2/qseq3/seq/create 1 32 3-tr808 bell 4
NETPD_SND: [..b] /2/qseq3/seq/create 1 32 3-tr808 bassdrum 4
NETPD_SND: [..b] /2/qseq3/seq/create 1 32 3-tr808 snare 4
NETPD_SND: [..b] /2/qseq3/element 1 0 0 1 0 0 0 0 0 1 [7]
NETPD_SND: [..b] /2/qseq3/element 1 1 0 0 0 0 0 1 0 0 [6]
NETPD_SND: [..b] /2/qseq3/element 1 3 0 1 1 0 0 1 1 0 [7]
NETPD_SND: [..b] /2/qseq3/element 1 5 0 1 1 1 1 1 1 1 [9]
NETPD_SND: [..b] /2/qseq3/element 1 8 0 1
NETPD_SND: [..b] /2/qseq3/element 1 9 0 0 0 0 0 0 0 0 [7]
NETPD_SND: [..b] /2/qseq3/element 1 10 0 0 0 0 0 0 0 0 [25]
NETPD_SND: [..b] /2/qseq3/element 1 11 0 0 0 0 0 0 0 0 [25]
NETPD_SND: [..b] /2/qseq3/1/metaseq/length 128
NETPD_SND: [..b] /2/qseq3/1/metaseq/offset 0
NETPD_SND: [..b] /2/qseq3/1/metaseq/set -1
NETPD_SND: [..b] /2/qseq3/dump/finished
NETPD_SND: [..b] /3/tr808/bl/pan 0.5
NETPD_SND: [..b] /3/tr808/bl/gain 0.511811
NETPD_SND: [..b] /3/tr808/bl/tune 0.496063
NETPD_SND: [..b] /3/tr808/cymbal/pan 0.5
NETPD_SND: [..b] /3/tr808/cymbal/gain 0.622047
NETPD_SND: [..b] /3/tr808/cymbal/tone 0
NETPD_SND: [..b] /3/tr808/cymbal/decay 0
NETPD_SND: [..b] /3/tr808/cymbal/tune 0.5
NETPD_SND: [..b] /3/tr808/hh/pan 0.5
NETPD_SND: [..b] /3/tr808/ohh/gain 0.771654
NETPD_SND: [..b] /3/tr808/chh/gain 0.637795
NETPD_SND: [..b] /3/tr808/hh/tune 0.5
NETPD_SND: [..b] /3/tr808/ohh/decay 0.5
NETPD_SND: [..b] /3/tr808/rim/pan 0.5
NETPD_SND: [..b] /3/tr808/rim/gain 0.409449
NETPD_SND: [..b] /3/tr808/snare/pan 0.5
NETPD_SND: [..b] /3/tr808/snare/tune 0.480315
NETPD_SND: [..b] /3/tr808/snare/snappy 0.755906
NETPD_SND: [..b] /3/tr808/snare/tone 0.5
NETPD_SND: [..b] /3/tr808/snare/gain 0.519685
NETPD_SND: [..b] /3/tr808/bassdrum/pan 0.5
NETPD_SND: [..b] /3/tr808/bassdrum/decay 0.629921
NETPD_SND: [..b] /3/tr808/bassdrum/click 0.425197
NETPD_SND: [..b] /3/tr808/bassdrum/gain 0.8
NETPD_SND: [..b] /3/tr808/mx/level 0.787402
NETPD_SND: [..b] /3/tr808/mx/pan 0.5
NETPD_SND: [..b] /3/tr808/mx/solo 0
NETPD_SND: [..b] /3/tr808/mx/mute 0
NETPD_SND: [..b] /3/tr808/mx/aux/3/level 0
NETPD_SND: [..b] /3/tr808/mx/aux/3/ch 0
NETPD_SND: [..b] /3/tr808/mx/aux/3/pp 0
NETPD_SND: [..b] /3/tr808/mx/aux/2/level 0
NETPD_SND: [..b] /3/tr808/mx/aux/2/ch 0
NETPD_SND: [..b] /3/tr808/mx/aux/2/pp 0
NETPD_SND: [..b] /3/tr808/mx/aux/1/level 0
NETPD_SND: [..b] /3/tr808/mx/aux/1/ch 0
NETPD_SND: [..b] /3/tr808/mx/aux/1/pp 0
NETPD_SND: [..b] /3/tr808/insert/3/load empty
NETPD_SND: [..b] /3/tr808/insert/3/bypass 0
NETPD_SND: [..b] /3/tr808/insert/2/load empty
NETPD_SND: [..b] /3/tr808/insert/2/bypass 0
NETPD_SND: [..b] /3/tr808/insert/1/load empty
NETPD_SND: [..b] /3/tr808/insert/1/bypass 0
NETPD_SND: [..b] /3/tr808/clap/pan 0.5
NETPD_SND: [..b] /3/tr808/clap/gain 0.8
NETPD_SND: [..b] /3/tr808/dump/finished
NETPD_SND: [..b] /unpatch/preset/load/end
NETPD_RCV: [..4] /unpatch/preset/load/start
NETPD_RCV: [..4] /unpatch/netcloseall
NETPD_RCV: [..4] /unpatch/netload 1 master
NETPD_RCV: [..4] /unpatch/netload 2 qseq3
NETPD_RCV: [..4] /unpatch/netload 3 tr808
NETPD_RCV: [..4] /unpatch/synced
NETPD_RCV: [..4] /1/master/bpm 110.762
NETPD_RCV: [..4] /1/master/shuffle 54.1353
NETPD_RCV: [..4] /1/master/mode 1
NETPD_RCV: [..4] /1/master/startstop 1
NETPD_RCV: [..4] /1/master/step 88.2656
NETPD_RCV: [..4] /1/master/dump/finished
NETPD_RCV: [..4] /2/qseq3/set/create 1
NETPD_RCV: [..4] /2/qseq3/seq/create 1 16 3-tr808 bassdrum 4
NETPD_RCV: [..4] /2/qseq3/seq/create 1 16 3-tr808 snare 4
NETPD_RCV: [..4] /2/qseq3/seq/create 1 16 3-tr808 clap 4
NETPD_RCV: [..4] /2/qseq3/seq/create 1 16 3-tr808 rimshot 4
NETPD_RCV: [..4] /2/qseq3/seq/create 1 16 3-tr808 ohihat 4
NETPD_RCV: [..4] /2/qseq3/seq/create 1 16 3-tr808 chihat 4
NETPD_RCV: [..4] /2/qseq3/seq/create 1 16 3-tr808 cymbal 4
NETPD_RCV: [..4] /2/qseq3/seq/create 1 16 3-tr808 bell 4
NETPD_RCV: [..4] /2/qseq3/seq/create 1 32 3-tr808 cymbal 4
NETPD_RCV: [..4] /2/qseq3/seq/create 1 32 3-tr808 bell 4
NETPD_RCV: [..4] /2/qseq3/seq/create 1 32 3-tr808 bassdrum 4
NETPD_RCV: [..4] /2/qseq3/seq/create 1 32 3-tr808 snare 4
NETPD_RCV: [..4] /2/qseq3/element 1 0 0 1 0 0 0 0 0 1 [7]
NETPD_RCV: [..4] /2/qseq3/element 1 1 0 0 0 0 0 1 0 0 [6]
NETPD_RCV: [..4] /2/qseq3/element 1 3 0 1 1 0 0 1 1 0 [7]
NETPD_RCV: [..4] /2/qseq3/element 1 5 0 1 1 1 1 1 1 1 [9]
NETPD_RCV: [..4] /2/qseq3/element 1 8 0 1
NETPD_RCV: [..4] /2/qseq3/element 1 9 0 0 0 0 0 0 0 0 [7]
NETPD_RCV: [..4] /2/qseq3/element 1 10 0 0 0 0 0 0 0 0 [25]
NETPD_RCV: [..4] /2/qseq3/element 1 11 0 0 0 0 0 0 0 0 [25]
NETPD_RCV: [..4] /2/qseq3/1/metaseq/length 128
NETPD_RCV: [..4] /2/qseq3/1/metaseq/offset 0
NETPD_RCV: [..4] /2/qseq3/1/metaseq/set -1
NETPD_RCV: [..4] /2/qseq3/dump/finished
NETPD_RCV: [..4] /3/tr808/bl/pan 0.5
NETPD_RCV: [..4] /3/tr808/bl/gain 0.511811
NETPD_RCV: [..4] /3/tr808/bl/tune 0.496063
NETPD_RCV: [..4] /3/tr808/cymbal/pan 0.5
NETPD_RCV: [..4] /3/tr808/cymbal/gain 0.622047
NETPD_RCV: [..4] /3/tr808/cymbal/tone 0
NETPD_RCV: [..4] /3/tr808/cymbal/decay 0
NETPD_RCV: [..4] /3/tr808/cymbal/tune 0.5
NETPD_RCV: [..4] /3/tr808/hh/pan 0.5
NETPD_RCV: [..4] /3/tr808/ohh/gain 0.771654
NETPD_RCV: [..4] /3/tr808/chh/gain 0.637795
NETPD_RCV: [..4] /3/tr808/hh/tune 0.5
NETPD_RCV: [..4] /3/tr808/ohh/decay 0.5
NETPD_RCV: [..4] /3/tr808/rim/pan 0.5
NETPD_RCV: [..4] /3/tr808/rim/gain 0.409449
NETPD_RCV: [..4] /3/tr808/snare/pan 0.5
NETPD_RCV: [..4] /3/tr808/snare/tune 0.480315
NETPD_RCV: [..4] /3/tr808/snare/snappy 0.755906
NETPD_RCV: [..4] /3/tr808/snare/tone 0.5
NETPD_RCV: [..4] /3/tr808/snare/gain 0.519685
NETPD_RCV: [..4] /3/tr808/bassdrum/pan 0.5
NETPD_RCV: [..4] /3/tr808/bassdrum/decay 0.629921
NETPD_RCV: [..4] /3/tr808/bassdrum/click 0.425197
NETPD_RCV: [..4] /3/tr808/bassdrum/gain 0.8
NETPD_RCV: [..4] /3/tr808/mx/level 0.787402
NETPD_RCV: [..4] /3/tr808/mx/pan 0.5
NETPD_RCV: [..4] /3/tr808/mx/solo 0
NETPD_RCV: [..4] /3/tr808/mx/mute 0
NETPD_RCV: [..4] /3/tr808/mx/aux/3/level 0
NETPD_RCV: [..4] /3/tr808/mx/aux/3/ch 0
NETPD_RCV: [..4] /3/tr808/mx/aux/3/pp 0
NETPD_RCV: [..4] /3/tr808/mx/aux/2/level 0
NETPD_RCV: [..4] /3/tr808/mx/aux/2/ch 0
NETPD_RCV: [..4] /3/tr808/mx/aux/2/pp 0
NETPD_RCV: [..4] /3/tr808/mx/aux/1/level 0
NETPD_RCV: [..4] /3/tr808/mx/aux/1/ch 0
NETPD_RCV: [..4] /3/tr808/mx/aux/1/pp 0
NETPD_RCV: [..4] /3/tr808/insert/3/load empty
NETPD_RCV: [..4] /3/tr808/insert/3/bypass 0
NETPD_RCV: [..4] /3/tr808/insert/2/load empty
NETPD_RCV: [..4] /3/tr808/insert/2/bypass 0
NETPD_RCV: [..4] /3/tr808/insert/1/load empty
NETPD_RCV: [..4] /3/tr808/insert/1/bypass 0
NETPD_RCV: [..4] /3/tr808/clap/pan 0.5
NETPD_RCV: [..4] /3/tr808/clap/gain 0.8
NETPD_RCV: [..4] /3/tr808/dump/finished
NETPD_RCV: [..4] /unpatch/preset/load/end
reduzent commented 1 year ago

The problem seems non-deterministic as it would lead to different result each time the preset is loaded. I did not find a way to reliably trigger the problem.

reduzent commented 1 year ago

I tried to re-save each abstraction used by qseq3 and the issue disappeared. I committed each re-save independently and the issue disappeared. I went back to the version before and the issue still didn't appear. What's happening here?

reduzent commented 1 year ago

I doesn't happen anymore and I don't know why. I close it anyway was resolved.

reduzent commented 1 year ago

It happens again.. why didn't it happen so many times in a row and now I can trigger the issue quite reliably?

reduzent commented 1 year ago

It appears this is not related at all to qseq3, but to the fact, that [netpd_head] uses a loadbang to initialize state. Because loadbang from the abstraction fires too early, the init message is delayed by [del 0]. If netpd receives many OSC messages within the same DSP tick, the netpd abstraction might get their state before they receive the init message, thus qseq3 creates some sets or sequences a second time. Using [netpd-slow-until 0] in [netpd-nb-until] instead of [until] in [netpd-funnel] (used to process messages in a non-blocking way) seems to prevent the race condition caused by [del 0] in [netpd_head].

Fixed by https://github.com/reduzent/netpd/commit/c890ca862fd986e298a33bb579555bb621145b4a