From faada59567f8cb252f4a909116595ce309ff5828 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Fri, 23 May 2003 12:29:55 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r647, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/miXed/; revision=648 --- LICENSE.txt | 31 + Makefile.common | 285 +++++++ ViCious/cyclone/sources | 184 ++++ cyclone/Makefile | 2 + cyclone/Makefile.dirs | 2 + cyclone/Makefile.objects | 24 + cyclone/Makefile.sources | 191 +++++ cyclone/build_counter | 3 + cyclone/cyclone-all.exclude | 9 + cyclone/cyclone-shared.include | 35 + cyclone/cyclone-test.exclude | 4 + cyclone/cyclone-vicious.exclude | 3 + cyclone/hammer/Append.c | 207 +++++ cyclone/hammer/Borax.c | 177 ++++ cyclone/hammer/Bucket.c | 137 +++ cyclone/hammer/Clip.c | 149 ++++ cyclone/hammer/Decode.c | 110 +++ cyclone/hammer/Histo.c | 103 +++ cyclone/hammer/Makefile | 3 + cyclone/hammer/Makefile.objects | 14 + cyclone/hammer/Makefile.sources | 80 ++ cyclone/hammer/MouseState.c | 153 ++++ cyclone/hammer/Peak.c | 63 ++ cyclone/hammer/TogEdge.c | 71 ++ cyclone/hammer/Trough.c | 63 ++ cyclone/hammer/Uzi.c | 108 +++ cyclone/hammer/accum.c | 68 ++ cyclone/hammer/acos.c | 48 ++ cyclone/hammer/active.c | 55 ++ cyclone/hammer/allhammers.c | 160 ++++ cyclone/hammer/anal.c | 108 +++ cyclone/hammer/asin.c | 48 ++ cyclone/hammer/bangbang.c | 73 ++ cyclone/hammer/bondo.c | 394 +++++++++ cyclone/hammer/buddy.c | 253 ++++++ cyclone/hammer/capture.c | 291 +++++++ cyclone/hammer/cartopol.c | 44 + cyclone/hammer/coll.c | 1597 +++++++++++++++++++++++++++++++++++ cyclone/hammer/comment.c | 835 ++++++++++++++++++ cyclone/hammer/cosh.c | 48 ++ cyclone/hammer/counter.c | 399 +++++++++ cyclone/hammer/cycle.c | 153 ++++ cyclone/hammer/decide.c | 75 ++ cyclone/hammer/drunk.c | 140 +++ cyclone/hammer/flush.c | 79 ++ cyclone/hammer/forward.c | 71 ++ cyclone/hammer/fromsymbol.c | 88 ++ cyclone/hammer/funbuff.c | 521 ++++++++++++ cyclone/hammer/funnel.c | 179 ++++ cyclone/hammer/gate.c | 147 ++++ cyclone/hammer/grab.c | 279 ++++++ cyclone/hammer/hammer.c | 93 ++ cyclone/hammer/iter.c | 112 +++ cyclone/hammer/match.c | 216 +++++ cyclone/hammer/maximum.c | 88 ++ cyclone/hammer/mean.c | 79 ++ cyclone/hammer/midiflush.c | 102 +++ cyclone/hammer/midiformat.c | 112 +++ cyclone/hammer/midiparse.c | 132 +++ cyclone/hammer/minimum.c | 88 ++ cyclone/hammer/mousefilter.c | 70 ++ cyclone/hammer/next.c | 58 ++ cyclone/hammer/offer.c | 94 +++ cyclone/hammer/onebang.c | 46 + cyclone/hammer/past.c | 154 ++++ cyclone/hammer/pd-lib-notes.txt | 61 ++ cyclone/hammer/poltocar.c | 44 + cyclone/hammer/prepend.c | 258 ++++++ cyclone/hammer/prob.c | 312 +++++++ cyclone/hammer/pv.c | 457 ++++++++++ cyclone/hammer/seq.c | 825 ++++++++++++++++++ cyclone/hammer/sinh.c | 48 ++ cyclone/hammer/speedlim.c | 173 ++++ cyclone/hammer/spell.c | 149 ++++ cyclone/hammer/split.c | 64 ++ cyclone/hammer/spray.c | 93 ++ cyclone/hammer/sprintf.c | 634 ++++++++++++++ cyclone/hammer/substitute.c | 340 ++++++++ cyclone/hammer/sustain.c | 85 ++ cyclone/hammer/switch.c | 152 ++++ cyclone/hammer/tanh.c | 48 ++ cyclone/hammer/testmess.c | 245 ++++++ cyclone/hammer/thresh.c | 134 +++ cyclone/hammer/tosymbol.c | 184 ++++ cyclone/hammer/universal.c | 167 ++++ cyclone/hammer/urn.c | 148 ++++ cyclone/hammer/xbendin.c | 93 ++ cyclone/hammer/xbendin2.c | 99 +++ cyclone/hammer/xbendout.c | 54 ++ cyclone/hammer/xbendout2.c | 60 ++ cyclone/hammer/xnotein.c | 100 +++ cyclone/hammer/xnoteout.c | 62 ++ cyclone/hammer/zl.c | 982 +++++++++++++++++++++ cyclone/shadow/Makefile | 7 + cyclone/shadow/Makefile.objects | 9 + cyclone/shadow/Makefile.sources | 6 + cyclone/shadow/cyclone.c | 159 ++++ cyclone/shadow/dummies.c | 664 +++++++++++++++ cyclone/shadow/nettles.c | 549 ++++++++++++ cyclone/shadow/shadow.h | 13 + cyclone/sickle/Clip.c | 59 ++ cyclone/sickle/Line.c | 299 +++++++ cyclone/sickle/Makefile | 3 + cyclone/sickle/Makefile.objects | 11 + cyclone/sickle/Makefile.sources | 67 ++ cyclone/sickle/Scope.c | 1043 +++++++++++++++++++++++ cyclone/sickle/Snapshot.c | 161 ++++ cyclone/sickle/abs.c | 42 + cyclone/sickle/acos.c | 48 ++ cyclone/sickle/acosh.c | 48 ++ cyclone/sickle/allpass.c | 153 ++++ cyclone/sickle/allsickles.c | 134 +++ cyclone/sickle/asin.c | 48 ++ cyclone/sickle/asinh.c | 48 ++ cyclone/sickle/atan.c | 48 ++ cyclone/sickle/atan2.c | 53 ++ cyclone/sickle/atanh.c | 48 ++ cyclone/sickle/average.c | 194 +++++ cyclone/sickle/avg.c | 62 ++ cyclone/sickle/bitand.c | 144 ++++ cyclone/sickle/bitnot.c | 66 ++ cyclone/sickle/bitor.c | 144 ++++ cyclone/sickle/bitshift.c | 130 +++ cyclone/sickle/bitxor.c | 144 ++++ cyclone/sickle/capture.c | 408 +++++++++ cyclone/sickle/cartopol.c | 79 ++ cyclone/sickle/change.c | 52 ++ cyclone/sickle/click.c | 119 +++ cyclone/sickle/comb.c | 162 ++++ cyclone/sickle/cosh.c | 48 ++ cyclone/sickle/cosx.c | 51 ++ cyclone/sickle/count.c | 145 ++++ cyclone/sickle/cycle.c | 173 ++++ cyclone/sickle/delay.c | 101 +++ cyclone/sickle/delta.c | 52 ++ cyclone/sickle/deltaclip.c | 67 ++ cyclone/sickle/edge.c | 106 +++ cyclone/sickle/frameaccum.c | 71 ++ cyclone/sickle/framedelta.c | 76 ++ cyclone/sickle/index.c | 107 +++ cyclone/sickle/kink.c | 62 ++ cyclone/sickle/linedrive.c | 73 ++ cyclone/sickle/log.c | 74 ++ cyclone/sickle/lookup.c | 94 +++ cyclone/sickle/minmax.c | 78 ++ cyclone/sickle/peakamp.c | 107 +++ cyclone/sickle/peek.c | 147 ++++ cyclone/sickle/phasewrap.c | 131 +++ cyclone/sickle/play.c | 122 +++ cyclone/sickle/poltocar.c | 79 ++ cyclone/sickle/pow.c | 54 ++ cyclone/sickle/rampsmooth.c | 206 +++++ cyclone/sickle/rand.c | 95 +++ cyclone/sickle/record.c | 242 ++++++ cyclone/sickle/sah.c | 70 ++ cyclone/sickle/sickle.c | 93 ++ cyclone/sickle/sinh.c | 48 ++ cyclone/sickle/sinx.c | 51 ++ cyclone/sickle/slide.c | 77 ++ cyclone/sickle/spike.c | 109 +++ cyclone/sickle/tanh.c | 48 ++ cyclone/sickle/tanx.c | 51 ++ cyclone/sickle/train.c | 117 +++ cyclone/sickle/trapezoid.c | 105 +++ cyclone/sickle/triangle.c | 95 +++ cyclone/sickle/vectral.c | 235 ++++++ cyclone/sickle/wave.c | 161 ++++ dumpsetups | 15 + shared/Makefile | 2 + shared/Makefile.dirs | 1 + shared/Makefile.objects | 0 shared/Makefile.sources | 2 + shared/common/Makefile | 4 + shared/common/Makefile.objects | 0 shared/common/Makefile.sources | 16 + shared/common/bifi.c | 217 +++++ shared/common/bifi.h | 40 + shared/common/binport.c | 559 ++++++++++++ shared/common/binport.h | 15 + shared/common/grow.c | 105 +++ shared/common/grow.h | 17 + shared/common/loud.c | 210 +++++ shared/common/loud.h | 31 + shared/common/mifi.c | 867 +++++++++++++++++++ shared/common/mifi.h | 84 ++ shared/common/port.c | 612 ++++++++++++++ shared/common/port.h | 10 + shared/common/rand.c | 61 ++ shared/common/rand.h | 14 + shared/common/sq.c | 371 ++++++++ shared/common/sq.h | 169 ++++ shared/common/vefl.c | 233 +++++ shared/common/vefl.h | 36 + shared/hammer/Makefile | 4 + shared/hammer/Makefile.objects | 0 shared/hammer/Makefile.sources | 4 + shared/hammer/file.c | 402 +++++++++ shared/hammer/file.h | 43 + shared/hammer/gui.c | 438 ++++++++++ shared/hammer/gui.h | 30 + shared/hammer/tree.c | 482 +++++++++++ shared/hammer/tree.h | 37 + shared/shared.c | 11 + shared/shared.h | 166 ++++ shared/sickle/Makefile | 4 + shared/sickle/Makefile.objects | 0 shared/sickle/Makefile.sources | 3 + shared/sickle/arsic.c | 221 +++++ shared/sickle/arsic.h | 38 + shared/sickle/sic.c | 119 +++ shared/sickle/sic.h | 25 + shared/unstable/Makefile | 4 + shared/unstable/Makefile.objects | 0 shared/unstable/Makefile.sources | 4 + shared/unstable/forky.c | 56 ++ shared/unstable/forky.h | 11 + shared/unstable/fragile.c | 67 ++ shared/unstable/fragile.h | 13 + shared/unstable/loader.c | 139 +++ shared/unstable/loader.h | 12 + shared/unstable/pd_imp.h | 60 ++ test/cyclone/Borax-test.pd | 120 +++ test/cyclone/Bucket-test.pd | 40 + test/cyclone/Decode-test.pd | 18 + test/cyclone/Histo-test.pd | 20 + test/cyclone/MouseState-test.pd | 54 ++ test/cyclone/TogEdge-test.pd | 16 + test/cyclone/Uzi-test.pd | 27 + test/cyclone/active-test.pd | 19 + test/cyclone/anal-test.pd | 17 + test/cyclone/append-test.pd | 78 ++ test/cyclone/bad.coll | 4 + test/cyclone/bondo-test.pd | 73 ++ test/cyclone/buddy-test.pd | 28 + test/cyclone/capture-test.pd | 48 ++ test/cyclone/click-test.pd | 26 + test/cyclone/clip-test.pd | 41 + test/cyclone/coll-print.pd | 12 + test/cyclone/coll-test.pd | 117 +++ test/cyclone/comb-test.pd | 80 ++ test/cyclone/comment-dotest.pd | 37 + test/cyclone/comment-ogonki.pd | 9 + test/cyclone/comment-test.pd | 21 + test/cyclone/count-test.pd | 19 + test/cyclone/counter-test.pd | 46 + test/cyclone/cycle-test.pd | 30 + test/cyclone/cyclone-test.pd | 54 ++ test/cyclone/decide-test.pd | 27 + test/cyclone/drunk-test.pd | 45 + test/cyclone/forward-test.pd | 27 + test/cyclone/frameaccum-test.pd | 15 + test/cyclone/fromsymbol-test.pd | 64 ++ test/cyclone/funbuff-etest.pd | 164 ++++ test/cyclone/funbuff-test.pd | 149 ++++ test/cyclone/funnel-test.pd | 33 + test/cyclone/gate-test.pd | 48 ++ test/cyclone/good.coll | 4 + test/cyclone/grab-test.pd | 42 + test/cyclone/index-test.pd | 51 ++ test/cyclone/kanon.mid | Bin 0 -> 5282 bytes test/cyclone/kink-test.pd | 22 + test/cyclone/line-test.pd | 54 ++ test/cyclone/match-reentrant.pd | 20 + test/cyclone/match-test.pd | 33 + test/cyclone/maxmin-test.pd | 65 ++ test/cyclone/mean-test.pd | 16 + test/cyclone/midi-test.pd | 33 + test/cyclone/midiparse-test.pd | 28 + test/cyclone/mousefilter-test.pd | 28 + test/cyclone/next-test.pd | 16 + test/cyclone/offer-test.pd | 76 ++ test/cyclone/onebang-test.pd | 26 + test/cyclone/past-test.pd | 38 + test/cyclone/peakamp-test.pd | 25 + test/cyclone/peek-test.pd | 51 ++ test/cyclone/prepend-test.pd | 73 ++ test/cyclone/prob-test.pd | 33 + test/cyclone/pv-test.pd | 83 ++ test/cyclone/rand-test.pd | 37 + test/cyclone/record-sync-test.pd | 64 ++ test/cyclone/record-test.pd | 60 ++ test/cyclone/scope-gop.pd | 2 + test/cyclone/scope-test.pd | 125 +++ test/cyclone/scope-test1.pd | 28 + test/cyclone/scope-test2.pd | 31 + test/cyclone/seq-test.pd | 58 ++ test/cyclone/sigbits-test.pd | 157 ++++ test/cyclone/sigcapture-test.pd | 25 + test/cyclone/sigcycle-test.pd | 156 ++++ test/cyclone/sigmeters-test.pd | 45 + test/cyclone/sigops-test.pd | 64 ++ test/cyclone/sigsmoothers-test.pd | 34 + test/cyclone/sigtrig-test.pd | 80 ++ test/cyclone/sigwrappers-speed.pd | 101 +++ test/cyclone/sigwrappers-speed20.pd | 63 ++ test/cyclone/sigwrappers-test.pd | 34 + test/cyclone/spectrum-pm.pd | 34 + test/cyclone/speedlim-test.pd | 63 ++ test/cyclone/spell-test.pd | 26 + test/cyclone/spike-test.pd | 23 + test/cyclone/split-test.pd | 48 ++ test/cyclone/spray-test.pd | 82 ++ test/cyclone/substitute-test.pd | 56 ++ test/cyclone/switch-test.pd | 35 + test/cyclone/test.capture | 2 + test/cyclone/test.funbuff | 10 + test/cyclone/test.mid | Bin 0 -> 4855 bytes test/cyclone/test.pool | 2 + test/cyclone/test.seq | 1208 ++++++++++++++++++++++++++ test/cyclone/test1.seq | 1208 ++++++++++++++++++++++++++ test/cyclone/testmess-reentrant.pd | 25 + test/cyclone/testmess-test.pd | 69 ++ test/cyclone/thresh-test.pd | 41 + test/cyclone/tosymbol-test.pd | 44 + test/cyclone/train-test.pd | 17 + test/cyclone/trig-test.pd | 66 ++ test/cyclone/universal-test.pd | 55 ++ test/cyclone/urn-test.pd | 15 + test/cyclone/vectral-test.pd | 56 ++ test/cyclone/xbend-test.pd | 89 ++ test/cyclone/xnote-test.pd | 50 ++ test/cyclone/zl-test.pd | 148 ++++ 322 files changed, 38287 insertions(+) create mode 100644 LICENSE.txt create mode 100644 Makefile.common create mode 100644 ViCious/cyclone/sources create mode 100644 cyclone/Makefile create mode 100644 cyclone/Makefile.dirs create mode 100644 cyclone/Makefile.objects create mode 100644 cyclone/Makefile.sources create mode 100644 cyclone/build_counter create mode 100644 cyclone/cyclone-all.exclude create mode 100644 cyclone/cyclone-shared.include create mode 100644 cyclone/cyclone-test.exclude create mode 100644 cyclone/cyclone-vicious.exclude create mode 100644 cyclone/hammer/Append.c create mode 100644 cyclone/hammer/Borax.c create mode 100644 cyclone/hammer/Bucket.c create mode 100644 cyclone/hammer/Clip.c create mode 100644 cyclone/hammer/Decode.c create mode 100644 cyclone/hammer/Histo.c create mode 100644 cyclone/hammer/Makefile create mode 100644 cyclone/hammer/Makefile.objects create mode 100644 cyclone/hammer/Makefile.sources create mode 100644 cyclone/hammer/MouseState.c create mode 100644 cyclone/hammer/Peak.c create mode 100644 cyclone/hammer/TogEdge.c create mode 100644 cyclone/hammer/Trough.c create mode 100644 cyclone/hammer/Uzi.c create mode 100644 cyclone/hammer/accum.c create mode 100644 cyclone/hammer/acos.c create mode 100644 cyclone/hammer/active.c create mode 100644 cyclone/hammer/allhammers.c create mode 100644 cyclone/hammer/anal.c create mode 100644 cyclone/hammer/asin.c create mode 100644 cyclone/hammer/bangbang.c create mode 100644 cyclone/hammer/bondo.c create mode 100644 cyclone/hammer/buddy.c create mode 100644 cyclone/hammer/capture.c create mode 100644 cyclone/hammer/cartopol.c create mode 100644 cyclone/hammer/coll.c create mode 100644 cyclone/hammer/comment.c create mode 100644 cyclone/hammer/cosh.c create mode 100644 cyclone/hammer/counter.c create mode 100644 cyclone/hammer/cycle.c create mode 100644 cyclone/hammer/decide.c create mode 100644 cyclone/hammer/drunk.c create mode 100644 cyclone/hammer/flush.c create mode 100644 cyclone/hammer/forward.c create mode 100644 cyclone/hammer/fromsymbol.c create mode 100644 cyclone/hammer/funbuff.c create mode 100644 cyclone/hammer/funnel.c create mode 100644 cyclone/hammer/gate.c create mode 100644 cyclone/hammer/grab.c create mode 100644 cyclone/hammer/hammer.c create mode 100644 cyclone/hammer/iter.c create mode 100644 cyclone/hammer/match.c create mode 100644 cyclone/hammer/maximum.c create mode 100644 cyclone/hammer/mean.c create mode 100644 cyclone/hammer/midiflush.c create mode 100644 cyclone/hammer/midiformat.c create mode 100644 cyclone/hammer/midiparse.c create mode 100644 cyclone/hammer/minimum.c create mode 100644 cyclone/hammer/mousefilter.c create mode 100644 cyclone/hammer/next.c create mode 100644 cyclone/hammer/offer.c create mode 100644 cyclone/hammer/onebang.c create mode 100644 cyclone/hammer/past.c create mode 100644 cyclone/hammer/pd-lib-notes.txt create mode 100644 cyclone/hammer/poltocar.c create mode 100644 cyclone/hammer/prepend.c create mode 100644 cyclone/hammer/prob.c create mode 100644 cyclone/hammer/pv.c create mode 100644 cyclone/hammer/seq.c create mode 100644 cyclone/hammer/sinh.c create mode 100644 cyclone/hammer/speedlim.c create mode 100644 cyclone/hammer/spell.c create mode 100644 cyclone/hammer/split.c create mode 100644 cyclone/hammer/spray.c create mode 100644 cyclone/hammer/sprintf.c create mode 100644 cyclone/hammer/substitute.c create mode 100644 cyclone/hammer/sustain.c create mode 100644 cyclone/hammer/switch.c create mode 100644 cyclone/hammer/tanh.c create mode 100644 cyclone/hammer/testmess.c create mode 100644 cyclone/hammer/thresh.c create mode 100644 cyclone/hammer/tosymbol.c create mode 100644 cyclone/hammer/universal.c create mode 100644 cyclone/hammer/urn.c create mode 100644 cyclone/hammer/xbendin.c create mode 100644 cyclone/hammer/xbendin2.c create mode 100644 cyclone/hammer/xbendout.c create mode 100644 cyclone/hammer/xbendout2.c create mode 100644 cyclone/hammer/xnotein.c create mode 100644 cyclone/hammer/xnoteout.c create mode 100644 cyclone/hammer/zl.c create mode 100644 cyclone/shadow/Makefile create mode 100644 cyclone/shadow/Makefile.objects create mode 100644 cyclone/shadow/Makefile.sources create mode 100644 cyclone/shadow/cyclone.c create mode 100644 cyclone/shadow/dummies.c create mode 100644 cyclone/shadow/nettles.c create mode 100644 cyclone/shadow/shadow.h create mode 100644 cyclone/sickle/Clip.c create mode 100644 cyclone/sickle/Line.c create mode 100644 cyclone/sickle/Makefile create mode 100644 cyclone/sickle/Makefile.objects create mode 100644 cyclone/sickle/Makefile.sources create mode 100644 cyclone/sickle/Scope.c create mode 100644 cyclone/sickle/Snapshot.c create mode 100644 cyclone/sickle/abs.c create mode 100644 cyclone/sickle/acos.c create mode 100644 cyclone/sickle/acosh.c create mode 100644 cyclone/sickle/allpass.c create mode 100644 cyclone/sickle/allsickles.c create mode 100644 cyclone/sickle/asin.c create mode 100644 cyclone/sickle/asinh.c create mode 100644 cyclone/sickle/atan.c create mode 100644 cyclone/sickle/atan2.c create mode 100644 cyclone/sickle/atanh.c create mode 100644 cyclone/sickle/average.c create mode 100644 cyclone/sickle/avg.c create mode 100644 cyclone/sickle/bitand.c create mode 100644 cyclone/sickle/bitnot.c create mode 100644 cyclone/sickle/bitor.c create mode 100644 cyclone/sickle/bitshift.c create mode 100644 cyclone/sickle/bitxor.c create mode 100644 cyclone/sickle/capture.c create mode 100644 cyclone/sickle/cartopol.c create mode 100644 cyclone/sickle/change.c create mode 100644 cyclone/sickle/click.c create mode 100644 cyclone/sickle/comb.c create mode 100644 cyclone/sickle/cosh.c create mode 100644 cyclone/sickle/cosx.c create mode 100644 cyclone/sickle/count.c create mode 100644 cyclone/sickle/cycle.c create mode 100644 cyclone/sickle/delay.c create mode 100644 cyclone/sickle/delta.c create mode 100644 cyclone/sickle/deltaclip.c create mode 100644 cyclone/sickle/edge.c create mode 100644 cyclone/sickle/frameaccum.c create mode 100644 cyclone/sickle/framedelta.c create mode 100644 cyclone/sickle/index.c create mode 100644 cyclone/sickle/kink.c create mode 100644 cyclone/sickle/linedrive.c create mode 100644 cyclone/sickle/log.c create mode 100644 cyclone/sickle/lookup.c create mode 100644 cyclone/sickle/minmax.c create mode 100644 cyclone/sickle/peakamp.c create mode 100644 cyclone/sickle/peek.c create mode 100644 cyclone/sickle/phasewrap.c create mode 100644 cyclone/sickle/play.c create mode 100644 cyclone/sickle/poltocar.c create mode 100644 cyclone/sickle/pow.c create mode 100644 cyclone/sickle/rampsmooth.c create mode 100644 cyclone/sickle/rand.c create mode 100644 cyclone/sickle/record.c create mode 100644 cyclone/sickle/sah.c create mode 100644 cyclone/sickle/sickle.c create mode 100644 cyclone/sickle/sinh.c create mode 100644 cyclone/sickle/sinx.c create mode 100644 cyclone/sickle/slide.c create mode 100644 cyclone/sickle/spike.c create mode 100644 cyclone/sickle/tanh.c create mode 100644 cyclone/sickle/tanx.c create mode 100644 cyclone/sickle/train.c create mode 100644 cyclone/sickle/trapezoid.c create mode 100644 cyclone/sickle/triangle.c create mode 100644 cyclone/sickle/vectral.c create mode 100644 cyclone/sickle/wave.c create mode 100755 dumpsetups create mode 100644 shared/Makefile create mode 100644 shared/Makefile.dirs create mode 100644 shared/Makefile.objects create mode 100644 shared/Makefile.sources create mode 100644 shared/common/Makefile create mode 100644 shared/common/Makefile.objects create mode 100644 shared/common/Makefile.sources create mode 100644 shared/common/bifi.c create mode 100644 shared/common/bifi.h create mode 100644 shared/common/binport.c create mode 100644 shared/common/binport.h create mode 100644 shared/common/grow.c create mode 100644 shared/common/grow.h create mode 100644 shared/common/loud.c create mode 100644 shared/common/loud.h create mode 100644 shared/common/mifi.c create mode 100644 shared/common/mifi.h create mode 100644 shared/common/port.c create mode 100644 shared/common/port.h create mode 100644 shared/common/rand.c create mode 100644 shared/common/rand.h create mode 100644 shared/common/sq.c create mode 100644 shared/common/sq.h create mode 100644 shared/common/vefl.c create mode 100644 shared/common/vefl.h create mode 100644 shared/hammer/Makefile create mode 100644 shared/hammer/Makefile.objects create mode 100644 shared/hammer/Makefile.sources create mode 100644 shared/hammer/file.c create mode 100644 shared/hammer/file.h create mode 100644 shared/hammer/gui.c create mode 100644 shared/hammer/gui.h create mode 100644 shared/hammer/tree.c create mode 100644 shared/hammer/tree.h create mode 100644 shared/shared.c create mode 100644 shared/shared.h create mode 100644 shared/sickle/Makefile create mode 100644 shared/sickle/Makefile.objects create mode 100644 shared/sickle/Makefile.sources create mode 100644 shared/sickle/arsic.c create mode 100644 shared/sickle/arsic.h create mode 100644 shared/sickle/sic.c create mode 100644 shared/sickle/sic.h create mode 100644 shared/unstable/Makefile create mode 100644 shared/unstable/Makefile.objects create mode 100644 shared/unstable/Makefile.sources create mode 100644 shared/unstable/forky.c create mode 100644 shared/unstable/forky.h create mode 100644 shared/unstable/fragile.c create mode 100644 shared/unstable/fragile.h create mode 100644 shared/unstable/loader.c create mode 100644 shared/unstable/loader.h create mode 100644 shared/unstable/pd_imp.h create mode 100644 test/cyclone/Borax-test.pd create mode 100644 test/cyclone/Bucket-test.pd create mode 100644 test/cyclone/Decode-test.pd create mode 100644 test/cyclone/Histo-test.pd create mode 100644 test/cyclone/MouseState-test.pd create mode 100644 test/cyclone/TogEdge-test.pd create mode 100644 test/cyclone/Uzi-test.pd create mode 100644 test/cyclone/active-test.pd create mode 100644 test/cyclone/anal-test.pd create mode 100644 test/cyclone/append-test.pd create mode 100644 test/cyclone/bad.coll create mode 100644 test/cyclone/bondo-test.pd create mode 100644 test/cyclone/buddy-test.pd create mode 100644 test/cyclone/capture-test.pd create mode 100644 test/cyclone/click-test.pd create mode 100644 test/cyclone/clip-test.pd create mode 100644 test/cyclone/coll-print.pd create mode 100644 test/cyclone/coll-test.pd create mode 100644 test/cyclone/comb-test.pd create mode 100644 test/cyclone/comment-dotest.pd create mode 100644 test/cyclone/comment-ogonki.pd create mode 100644 test/cyclone/comment-test.pd create mode 100644 test/cyclone/count-test.pd create mode 100644 test/cyclone/counter-test.pd create mode 100644 test/cyclone/cycle-test.pd create mode 100644 test/cyclone/cyclone-test.pd create mode 100644 test/cyclone/decide-test.pd create mode 100644 test/cyclone/drunk-test.pd create mode 100644 test/cyclone/forward-test.pd create mode 100644 test/cyclone/frameaccum-test.pd create mode 100644 test/cyclone/fromsymbol-test.pd create mode 100644 test/cyclone/funbuff-etest.pd create mode 100644 test/cyclone/funbuff-test.pd create mode 100644 test/cyclone/funnel-test.pd create mode 100644 test/cyclone/gate-test.pd create mode 100644 test/cyclone/good.coll create mode 100644 test/cyclone/grab-test.pd create mode 100644 test/cyclone/index-test.pd create mode 100644 test/cyclone/kanon.mid create mode 100644 test/cyclone/kink-test.pd create mode 100644 test/cyclone/line-test.pd create mode 100644 test/cyclone/match-reentrant.pd create mode 100644 test/cyclone/match-test.pd create mode 100644 test/cyclone/maxmin-test.pd create mode 100644 test/cyclone/mean-test.pd create mode 100644 test/cyclone/midi-test.pd create mode 100644 test/cyclone/midiparse-test.pd create mode 100644 test/cyclone/mousefilter-test.pd create mode 100644 test/cyclone/next-test.pd create mode 100644 test/cyclone/offer-test.pd create mode 100644 test/cyclone/onebang-test.pd create mode 100644 test/cyclone/past-test.pd create mode 100644 test/cyclone/peakamp-test.pd create mode 100644 test/cyclone/peek-test.pd create mode 100644 test/cyclone/prepend-test.pd create mode 100644 test/cyclone/prob-test.pd create mode 100644 test/cyclone/pv-test.pd create mode 100644 test/cyclone/rand-test.pd create mode 100644 test/cyclone/record-sync-test.pd create mode 100644 test/cyclone/record-test.pd create mode 100644 test/cyclone/scope-gop.pd create mode 100644 test/cyclone/scope-test.pd create mode 100644 test/cyclone/scope-test1.pd create mode 100644 test/cyclone/scope-test2.pd create mode 100644 test/cyclone/seq-test.pd create mode 100644 test/cyclone/sigbits-test.pd create mode 100644 test/cyclone/sigcapture-test.pd create mode 100644 test/cyclone/sigcycle-test.pd create mode 100644 test/cyclone/sigmeters-test.pd create mode 100644 test/cyclone/sigops-test.pd create mode 100644 test/cyclone/sigsmoothers-test.pd create mode 100644 test/cyclone/sigtrig-test.pd create mode 100644 test/cyclone/sigwrappers-speed.pd create mode 100644 test/cyclone/sigwrappers-speed20.pd create mode 100644 test/cyclone/sigwrappers-test.pd create mode 100644 test/cyclone/spectrum-pm.pd create mode 100644 test/cyclone/speedlim-test.pd create mode 100644 test/cyclone/spell-test.pd create mode 100644 test/cyclone/spike-test.pd create mode 100644 test/cyclone/split-test.pd create mode 100644 test/cyclone/spray-test.pd create mode 100644 test/cyclone/substitute-test.pd create mode 100644 test/cyclone/switch-test.pd create mode 100644 test/cyclone/test.capture create mode 100644 test/cyclone/test.funbuff create mode 100644 test/cyclone/test.mid create mode 100644 test/cyclone/test.pool create mode 100644 test/cyclone/test.seq create mode 100644 test/cyclone/test1.seq create mode 100644 test/cyclone/testmess-reentrant.pd create mode 100644 test/cyclone/testmess-test.pd create mode 100644 test/cyclone/thresh-test.pd create mode 100644 test/cyclone/tosymbol-test.pd create mode 100644 test/cyclone/train-test.pd create mode 100644 test/cyclone/trig-test.pd create mode 100644 test/cyclone/universal-test.pd create mode 100644 test/cyclone/urn-test.pd create mode 100644 test/cyclone/vectral-test.pd create mode 100644 test/cyclone/xbend-test.pd create mode 100644 test/cyclone/xnote-test.pd create mode 100644 test/cyclone/zl-test.pd diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..34ee839 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,31 @@ +This software is copyrighted by Miller Puckette and others. The following +terms apply to all files associated with the software unless explicitly +disclaimed in individual files. + +The authors hereby grant permission to use, copy, modify, distribute, +and license this software and its documentation for any purpose, provided +that existing copyright notices are retained in all copies and that this +notice is included verbatim in any distributions. No written agreement, +license, or royalty fee is required for any of the authorized uses. +Modifications to this software may be copyrighted by their authors +and need not follow the licensing terms described here, provided that +the new terms are clearly indicated on the first page of each file where +they apply. + +IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY +FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY +DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE +IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE +NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. + +RESTRICTED RIGHTS: Use, duplication or disclosure by the government +is subject to the restrictions as set forth in subparagraph (c) (1) (ii) +of the Rights in Technical Data and Computer Software Clause as DFARS +252.227-7013 and FAR 52.227-19. diff --git a/Makefile.common b/Makefile.common new file mode 100644 index 0000000..3db7717 --- /dev/null +++ b/Makefile.common @@ -0,0 +1,285 @@ +# next line has to be edited manually +PD_DIR = $(ROOT_DIR)/../pd/src + +OS_NAME = $(shell uname -s) +ifneq ($(OS_NAME),Linux) +ifneq ($(OS_NAME),Darwin) +# FIXME +endif +endif + +TILDE = ~ + +-include Makefile.dirs +include Makefile.sources +include Makefile.objects + +CC = gcc + +default: define_build all + +SHARED_DIR = $(ROOT_DIR)/shared +OBJ_DIR = . +OUT_DIR = $(ROOT_DIR)/bin + +BASE_DIR = $(shell basename `pwd`) +BASE_NAME = $(shell basename `pwd` | awk -F - '{print $$1}') + +# CX: control external's main file +# AX: audio (tilde) external's main file +# LX: symlink external's main file +# (if symlink external is tilde-only, use OTHER_SOURCES and AX_CLASSES) + +CX_NAMES = $(notdir $(CX_SOURCES)) +AX_NAMES = $(notdir $(AX_SOURCES)) +LX_NAMES = $(notdir $(LX_SOURCES)) +TYPES_NAMES = $(notdir $($1_SOURCES)) + +CX_DIR = $(dir $(firstword $(CX_SOURCES))) +AX_DIR = $(dir $(firstword $(AX_SOURCES))) +TYPES_DIR = $(dir $(firstword $($1_SOURCES))) + +TYPES_EXTERNS = \ + $(patsubst %.c,%$($1_TILDE).$(X_SUFFIX),$(call TYPES_NAMES,$1)) + +SOURCES = $(CX_SOURCES) $(AX_SOURCES) $(LX_SOURCES) $(OTHER_SOURCES) \ + $(foreach type,$(TYPES),$($(type)_SOURCES)) + +INCLUDES = -I. -I$(PD_DIR) -I$(SHARED_DIR) + +ifeq ($(OS_NAME),Linux) +X_SUFFIX = pd_linux +DEFINES = -DUNIX +OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer +LFLAGS = -export_dynamic -shared +endif + +ifeq ($(OS_NAME),Darwin) +X_SUFFIX = pd_darwin +DEFINES = -DUNIX -DMACOSX +OPT_CFLAGS = -O2 -funroll-loops -fomit-frame-pointer +# -private_bundle is a guess, LATER check this +LFLAGS = -bundle -undefined suppress -flat_namespace +endif + +WARN_CFLAGS = -Wall -W -Wstrict-prototypes -Werror \ + -Wno-unused -Wno-parentheses -Wno-switch +DBG_CFLAGS = +CFLAGS = $(WARN_CFLAGS) $(OPT_CFLAGS) $(DEFINES) $(INCLUDES) + +EXTERNS = $(foreach fn,$(CX_NAMES:.c=.$(X_SUFFIX)),$(OUT_DIR)/$(fn)) \ + $(foreach fn,$(AX_NAMES:.c=~.$(X_SUFFIX)),$(OUT_DIR)/$(fn)) \ + $(foreach fn,$(LX_SOURCES:.c=.$(X_SUFFIX)),$(OUT_DIR)/$(fn)) \ + $(foreach fn,$(CX_CLASSES:=.$(X_SUFFIX)),$(OUT_DIR)/$(fn)) \ + $(foreach fn,$(AX_CLASSES:=~.$(X_SUFFIX)),$(OUT_DIR)/$(fn)) \ + $(foreach type,$(TYPES),\ + $(foreach fn,$(call TYPES_EXTERNS,$(type)),$(OUT_DIR)/$(fn))) + +TYPES_RULE = $(foreach fn,$(call TYPES_EXTERNS,$1),$(OUT_DIR)/$(fn)): \ + $(OUT_DIR)/%$($1_TILDE).$(X_SUFFIX) \ + : $(call TYPES_DIR,$1)%.o $($1_PRIVATEOBJECTS) \ + $(foreach obj,$($1_OBJECTS),$(SHARED_DIR)/$(obj)) \ + ; $(CC) -o $$@ $(CFLAGS) $(LFLAGS) $$+ + +# LATER find a better way... +$(if $(word 1,$(TYPES)),$(call TYPES_RULE,$(word 1,$(TYPES)))) +$(if $(word 2,$(TYPES)),$(call TYPES_RULE,$(word 2,$(TYPES)))) +$(if $(word 3,$(TYPES)),$(call TYPES_RULE,$(word 3,$(TYPES)))) +$(if $(word 4,$(TYPES)),$(call TYPES_RULE,$(word 4,$(TYPES)))) +$(if $(word 5,$(TYPES)),$(call TYPES_RULE,$(word 5,$(TYPES)))) +$(if $(word 6,$(TYPES)),$(call TYPES_RULE,$(word 6,$(TYPES)))) +$(if $(word 7,$(TYPES)),$(call TYPES_RULE,$(word 7,$(TYPES)))) +$(if $(word 8,$(TYPES)),$(call TYPES_RULE,$(word 8,$(TYPES)))) +$(if $(word 9,$(TYPES)),$(call TYPES_RULE,$(word 9,$(TYPES)))) +$(if $(word 10,$(TYPES)),$(call TYPES_RULE,$(word 10,$(TYPES)))) +$(if $(word 11,$(TYPES)),$(call TYPES_RULE,$(word 11,$(TYPES)))) +$(if $(word 12,$(TYPES)),$(call TYPES_RULE,$(word 12,$(TYPES)))) +$(if $(word 13,$(TYPES)),$(call TYPES_RULE,$(word 13,$(TYPES)))) +$(if $(word 14,$(TYPES)),$(call TYPES_RULE,$(word 14,$(TYPES)))) +$(if $(word 15,$(TYPES)),$(call TYPES_RULE,$(word 15,$(TYPES)))) +$(if $(word 16,$(TYPES)),$(call TYPES_RULE,$(word 16,$(TYPES)))) +$(if $(word 17,$(TYPES)),$(call TYPES_RULE,$(word 17,$(TYPES)))) +$(if $(word 18,$(TYPES)),$(call TYPES_RULE,$(word 18,$(TYPES)))) +$(if $(word 19,$(TYPES)),$(call TYPES_RULE,$(word 19,$(TYPES)))) +$(if $(word 20,$(TYPES)),$(call TYPES_RULE,$(word 20,$(TYPES)))) +$(if $(word 21,$(TYPES)),$(call TYPES_RULE,$(word 21,$(TYPES)))) +$(if $(word 22,$(TYPES)),$(call TYPES_RULE,$(word 22,$(TYPES)))) +$(if $(word 23,$(TYPES)),$(call TYPES_RULE,$(word 23,$(TYPES)))) +$(if $(word 24,$(TYPES)),$(call TYPES_RULE,$(word 24,$(TYPES)))) + +OBJECTS = $(foreach fn,$(OTHER_SOURCES:.c=.o),$(OBJ_DIR)/$(fn)) \ + $(foreach fn,$(LX_SOURCES:.c=.o),$(OBJ_DIR)/$(fn)) \ + $(foreach fn,$(SHARED_OBJECTS),$(SHARED_DIR)/$(fn)) + +# lame... +.PRECIOUS: %.o + +# rules for symlink externals must precede generic extern rules +$(OUT_DIR)/$(BASE_NAME)_%~.$(X_SUFFIX): $(OUT_DIR)/$(BASE_NAME).$(X_SUFFIX) + -ln -sf $(BASE_NAME).$(X_SUFFIX) $@ +$(OUT_DIR)/$(BASE_NAME)_%.$(X_SUFFIX): $(OUT_DIR)/$(BASE_NAME).$(X_SUFFIX) + -ln -sf $(BASE_NAME).$(X_SUFFIX) $@ + +# library stub +# if not equal BASE_NAME, it has to be declared explicitly in BASE_DIR/Makefile +$(OUT_DIR)/$(LX_STUB)_%~.$(X_SUFFIX): $(OUT_DIR)/$(BASE_NAME).$(X_SUFFIX) + -ln -sf $(BASE_NAME).$(X_SUFFIX) $@ +$(OUT_DIR)/$(LX_STUB)_%.$(X_SUFFIX): $(OUT_DIR)/$(BASE_NAME).$(X_SUFFIX) + -ln -sf $(BASE_NAME).$(X_SUFFIX) $@ +$(OUT_DIR)/$(LX_STUB).$(X_SUFFIX): $(OUT_DIR)/$(BASE_NAME).$(X_SUFFIX) + -ln -sf $(BASE_NAME).$(X_SUFFIX) $@ + +# generic rule for audio externals +$(OUT_DIR)/%~.$(X_SUFFIX): $(AX_DIR)%.c $(OBJECTS) + $(CC) -o $@ $(CFLAGS) $(LFLAGS) $(OBJECTS) $< + +# generic rule for control externals +$(OUT_DIR)/%.$(X_SUFFIX): $(CX_DIR)%.c $(OBJECTS) + $(CC) -o $@ $(CFLAGS) $(LFLAGS) $(OBJECTS) $< + +SUBDIRS = @for i in $(MIXED_DIRS) and_in_case_it_is_null ; \ + do ( if [ -d $$i ] ; then \ + cd $$i; $(MAKE) $@ ; fi ) ; done + +SUBDIRS_DEFAULT = @for i in $(MIXED_DIRS) and_in_case_it_is_null ; \ + do ( if [ -d $$i ] ; then \ + cd $$i; $(MAKE) ; fi ) ; done + +define_build: + @if [[ -f build_counter && \ + `date -r build_counter +%j` != `date +%j` ]] ; then \ + mv build_counter build_counter~ ; \ + echo -n 'increment build counter (y/n)? [n]' ; read doit ; \ + if [ $$doit ] && [ $$doit == 'y' ] ; then \ + cat build_counter~ | \ + awk '{if (index($$2,"BUILD")) print $$1, $$2, $$3+1; else print}' \ + > build_counter ; \ + cat build_counter | \ + awk 'BEGIN {printf toupper("$(BASE_NAME)_VERSION = ")} \ + {gsub("\"","",$$3); printf $$3; if (NR==1) printf "-"} \ + END {printf "\r\n" }' > $(ROOT_DIR)/ViCious/$(BASE_DIR)/version ; \ + else cat build_counter~ > build_counter ; fi \ + fi + +all$(BASE_NAME)s.c: Makefile.sources + $(ROOT_DIR)/dumpsetups > $@ + +all: $(EXTERNS) + $(SUBDIRS_DEFAULT) + +clean: emptydeps +# remove all objects and externs that are contained in current directory + -rm -f *.o *.$(X_SUFFIX) + $(SUBDIRS) + +cleanall: clean +# remove default target externs + -rm -f $(EXTERNS) + +OLDROOT_DIR = $(shell ls -d -1 ../../Mixed-* | tail -1) + +diff: + @echo -n > diff.out ; \ + for f in {*.h,*.c} ; do \ + if [ -f $$f ] ; then \ + diff -u $(OLDROOT_DIR)/$(BASE_DIR)/$$f $$f >> diff.out ; \ + fi \ + done + +VERSION = $(shell awk \ + '{if (index($$2,"VERSION")) print substr($$3,2,length($$3)-2)}' \ + build_counter) +RELEASE = $(shell awk \ + '{if (index($$2,"RELEASE")) print substr($$3,2,length($$3)-2)}' \ + build_counter) +BUILD = $(shell awk '{if (index($$2,"BUILD")) print $$3}' build_counter) + +RELEASE_STUB = release/$(BASE_NAME)-$(VERSION)-$(RELEASE)$(BUILD) +SRC_TAR = $(RELEASE_STUB)-src.tar +BIN_TAR = $(RELEASE_STUB)-bin.tar +LIB_TAR = $(RELEASE_STUB)-lib.tar +DOC_TAR = $(RELEASE_STUB)-doc.tar +ALL_TAR = $(RELEASE_STUB)-all.tar +REL_BINDIR = bin + +REL_LIBNAMES = $(foreach fn,$(RELEASE_LIBS:=.$(X_SUFFIX)),$(REL_BINDIR)/$(fn)) + +REL_EXTERNS = $(foreach fn,$(CX_NAMES:.c=.$(X_SUFFIX)),$(REL_BINDIR)/$(fn)) \ + $(foreach fn,$(AX_NAMES:.c=~.$(X_SUFFIX)),$(REL_BINDIR)/$(fn)) \ + $(REL_LIBNAMES) $(REL_BINDIR)/$(RELEASE_APPS) \ + $(foreach type,$(TYPES),\ + $(foreach fn,$(call TYPES_EXTERNS,$(type)),$(REL_BINDIR)/$(fn))) + +REL_ROOTSRC = LICENSE.txt Makefile.common dumpsetups + +srelease: emptydeps define_build + cd $(ROOT_DIR)/shared; $(MAKE) emptydeps + cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-all.exclude -cf \ + $(SRC_TAR) $(BASE_DIR)/* $(REL_ROOTSRC) + cd $(ROOT_DIR); tar -T $(BASE_DIR)/$(BASE_NAME)-shared.include -rf \ + $(SRC_TAR) + cd $(ROOT_DIR); gzip -f $(SRC_TAR) + +stestrelease: emptydeps define_build + cd $(ROOT_DIR)/shared; $(MAKE) emptydeps + cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-all.exclude -cf \ + $(SRC_TAR) $(BASE_DIR)/* $(REL_ROOTSRC) + cd $(ROOT_DIR); tar -T $(BASE_DIR)/$(BASE_NAME)-shared.include -rf \ + $(SRC_TAR) + cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-test.exclude -rf \ + $(SRC_TAR) test/$(BASE_NAME)/* + cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-vicious.exclude -rf \ + $(SRC_TAR) ViCious/$(BASE_DIR)/* + cd $(ROOT_DIR); gzip -f $(SRC_TAR) + +brelease: define_build + cd $(ROOT_DIR); tar zcf \ + $(BIN_TAR).gz $(REL_EXTERNS) + +rellibs: + cd $(ROOT_DIR); tar zcf \ + $(LIB_TAR).gz $(REL_LIBNAMES) + +drelease: define_build + cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-doc.exclude -zcf \ + $(DOC_TAR).gz doc/examples/$(BASE_NAME)/* + +release: srelease brelease drelease + cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-all.exclude -cf \ + $(ALL_TAR) $(BASE_DIR)/* $(REL_ROOTSRC) $(REL_EXTERNS) + cd $(ROOT_DIR); tar -T $(BASE_DIR)/$(BASE_NAME)-shared.include -rf \ + $(ALL_TAR) + cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-doc.exclude -rf \ + $(ALL_TAR) doc/examples/$(BASE_NAME)/* + cd $(ROOT_DIR); gzip -f $(ALL_TAR) + +testrelease: stestrelease brelease + cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-all.exclude -cf \ + $(ALL_TAR) $(BASE_DIR)/* $(REL_ROOTSRC) $(REL_EXTERNS) + cd $(ROOT_DIR); tar -T $(BASE_DIR)/$(BASE_NAME)-shared.include -rf \ + $(ALL_TAR) + cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-test.exclude -rf \ + $(ALL_TAR) test/$(BASE_NAME)/* + cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-vicious.exclude -rf \ + $(ALL_TAR) ViCious/$(BASE_DIR)/* + cd $(ROOT_DIR); gzip -f $(ALL_TAR) + +snap: emptyalldeps testrelease rellibs + +depend: + $(CC) $(CFLAGS) -M $(SOURCES) > Makefile.deps + $(SUBDIRS) + +emptydeps: + -rm -f Makefile.deps + touch Makefile.deps + chmod 666 Makefile.deps + +emptyalldeps: emptydeps + $(SUBDIRS) + +Makefile.deps: + touch Makefile.deps + chmod 666 Makefile.deps + +-include Makefile.deps diff --git a/ViCious/cyclone/sources b/ViCious/cyclone/sources new file mode 100644 index 0000000..cf37233 --- /dev/null +++ b/ViCious/cyclone/sources @@ -0,0 +1,184 @@ +LIB_CYCLONE = \ + shadow\cyclone.c \ + shadow\nettles.c \ + shadow\dummies.c \ + shared\common\loud.c \ + shared\common\grow.c \ + shared\common\binport.c \ + shared\common\port.c \ + shared\hammer\file.c \ + shared\sickle\sic.c \ + shared\unstable\fragile.c \ + shared\unstable\loader.c + +LIB_HAMMER = \ + hammer\hammer.c \ + hammer\allhammers.c \ + shared\common\loud.c \ + shared\common\grow.c \ + shared\common\rand.c \ + shared\common\vefl.c \ + shared\common\sq.c \ + shared\common\bifi.c \ + shared\common\mifi.c \ + shared\common\binport.c \ + shared\common\port.c \ + shared\hammer\file.c \ + shared\hammer\gui.c \ + shared\hammer\tree.c \ + shared\unstable\fragile.c + +ALL_HAMMERS = \ + hammer\testmess.c \ + hammer\accum.c \ + hammer\acos.c \ + hammer\active.c \ + hammer\anal.c \ + hammer\Append.c \ + hammer\asin.c \ + hammer\bangbang.c \ + hammer\bondo.c \ + hammer\Borax.c \ + hammer\Bucket.c \ + hammer\buddy.c \ + hammer\capture.c \ + hammer\cartopol.c \ + hammer\Clip.c \ + hammer\coll.c \ + hammer\comment.c \ + hammer\cosh.c \ + hammer\counter.c \ + hammer\cycle.c \ + hammer\decide.c \ + hammer\Decode.c \ + hammer\drunk.c \ + hammer\flush.c \ + hammer\forward.c \ + hammer\fromsymbol.c \ + hammer\funbuff.c \ + hammer\funnel.c \ + hammer\gate.c \ + hammer\grab.c \ + hammer\Histo.c \ + hammer\iter.c \ + hammer\match.c \ + hammer\maximum.c \ + hammer\mean.c \ + hammer\midiflush.c \ + hammer\midiformat.c \ + hammer\midiparse.c \ + hammer\minimum.c \ + hammer\mousefilter.c \ + hammer\MouseState.c \ + hammer\next.c \ + hammer\offer.c \ + hammer\onebang.c \ + hammer\past.c \ + hammer\Peak.c \ + hammer\poltocar.c \ + hammer\prepend.c \ + hammer\prob.c \ + hammer\pv.c \ + hammer\seq.c \ + hammer\sinh.c \ + hammer\speedlim.c \ + hammer\spell.c \ + hammer\split.c \ + hammer\spray.c \ + hammer\sprintf.c \ + hammer\substitute.c \ + hammer\sustain.c \ + hammer\switch.c \ + hammer\tanh.c \ + hammer\thresh.c \ + hammer\TogEdge.c \ + hammer\tosymbol.c \ + hammer\Trough.c \ + hammer\universal.c \ + hammer\urn.c \ + hammer\Uzi.c \ + hammer\xbendin.c \ + hammer\xbendin2.c \ + hammer\xbendout.c \ + hammer\xbendout2.c \ + hammer\xnotein.c \ + hammer\xnoteout.c \ + hammer\zl.c + +LIB_SICKLE = \ + sickle\sickle.c \ + sickle\allsickles.c \ + shared\common\loud.c \ + shared\common\grow.c \ + shared\common\vefl.c \ + shared\common\binport.c \ + shared\common\port.c \ + shared\hammer\file.c \ + shared\sickle\sic.c \ + shared\sickle\arsic.c \ + shared\unstable\forky.c \ + shared\unstable\fragile.c + +ALL_SICKLES = \ + sickle\abs.c \ + sickle\acos.c \ + sickle\acosh.c \ + sickle\allpass.c \ + sickle\asin.c \ + sickle\asinh.c \ + sickle\atan.c \ + sickle\atan2.c \ + sickle\atanh.c \ + sickle\average.c \ + sickle\avg.c \ + sickle\bitand.c \ + sickle\bitnot.c \ + sickle\bitor.c \ + sickle\bitshift.c \ + sickle\bitxor.c \ + sickle\capture.c \ + sickle\cartopol.c \ + sickle\change.c \ + sickle\click.c \ + sickle\Clip.c \ + sickle\comb.c \ + sickle\cosh.c \ + sickle\cosx.c \ + sickle\count.c \ + sickle\cycle.c \ + sickle\delay.c \ + sickle\delta.c \ + sickle\deltaclip.c \ + sickle\edge.c \ + sickle\frameaccum.c \ + sickle\framedelta.c \ + sickle\index.c \ + sickle\kink.c \ + sickle\Line.c \ + sickle\linedrive.c \ + sickle\log.c \ + sickle\lookup.c \ + sickle\minmax.c \ + sickle\peakamp.c \ + sickle\peek.c \ + sickle\phasewrap.c \ + sickle\play.c \ + sickle\poltocar.c \ + sickle\pow.c \ + sickle\rand.c \ + sickle\rampsmooth.c \ + sickle\record.c \ + sickle\sah.c \ + sickle\Scope.c \ + sickle\sinh.c \ + sickle\sinx.c \ + sickle\slide.c \ + sickle\Snapshot.c \ + sickle\spike.c \ + sickle\tanh.c \ + sickle\tanx.c \ + sickle\train.c \ + sickle\trapezoid.c \ + sickle\triangle.c \ + sickle\vectral.c \ + sickle\wave.c diff --git a/cyclone/Makefile b/cyclone/Makefile new file mode 100644 index 0000000..fc022be --- /dev/null +++ b/cyclone/Makefile @@ -0,0 +1,2 @@ +ROOT_DIR = .. +include $(ROOT_DIR)/Makefile.common diff --git a/cyclone/Makefile.dirs b/cyclone/Makefile.dirs new file mode 100644 index 0000000..0dde72f --- /dev/null +++ b/cyclone/Makefile.dirs @@ -0,0 +1,2 @@ +MIXED_DIRS = shadow hammer sickle +RELEASE_DIRS = shadow hammer sickle diff --git a/cyclone/Makefile.objects b/cyclone/Makefile.objects new file mode 100644 index 0000000..9b421fe --- /dev/null +++ b/cyclone/Makefile.objects @@ -0,0 +1,24 @@ +HLOUD_OBJECTS = common/loud.o +HFRAGILE_OBJECTS = common/loud.o unstable/fragile.o +HGROW_OBJECTS = common/grow.o common/loud.o +HFILE_OBJECTS = hammer/file.o common/loud.o +HRAND_OBJECTS = common/rand.o common/loud.o +HRANDFILE_OBJECTS = common/rand.o hammer/file.o common/loud.o +HRANDGROW_OBJECTS = common/rand.o common/grow.o common/loud.o +HTREE_OBJECTS = hammer/tree.o common/loud.o +HTREEFILEVEFL_OBJECTS = hammer/tree.o hammer/file.o \ + common/vefl.o common/loud.o unstable/fragile.o +HGUI_OBJECTS = hammer/gui.o common/loud.o +HSEQ_OBJECTS = common/sq.o common/bifi.o common/mifi.o \ + hammer/file.o common/grow.o common/loud.o +SSIC_OBJECTS = sickle/sic.o common/loud.o +SFORKY_OBJECTS = sickle/sic.o common/loud.o unstable/forky.o +SFRAGILE_OBJECTS = sickle/sic.o common/loud.o unstable/fragile.o +SGROW_OBJECTS = common/grow.o sickle/sic.o common/loud.o +SGROWFORKY_OBJECTS = common/grow.o sickle/sic.o common/loud.o unstable/forky.o +SVEFL_OBJECTS = common/vefl.o sickle/sic.o common/loud.o unstable/fragile.o +SARSIC_OBJECTS = sickle/sic.o sickle/arsic.o common/vefl.o \ + common/loud.o unstable/fragile.o +SFILE_OBJECTS = hammer/file.o sickle/sic.o common/loud.o +RELEASE_LIBS = cyclone hammer sickle +RELEASE_APPS = cyclist diff --git a/cyclone/Makefile.sources b/cyclone/Makefile.sources new file mode 100644 index 0000000..4d6cc29 --- /dev/null +++ b/cyclone/Makefile.sources @@ -0,0 +1,191 @@ +TYPES = HPLAIN HLOUD HFRAGILE HGROW HFILE HRAND HRANDFILE HRANDGROW \ + HTREE HTREEFILEVEFL HGUI HSEQ \ + SPLAINNOTILDE SPLAIN SSIC SFORKY SFRAGILE SGROW SGROWFORKY \ + SVEFL SARSIC SFILE + +HPLAIN_SOURCES = \ +hammer/testmess.c \ +hammer/accum.c \ +hammer/acos.c \ +hammer/asin.c \ +hammer/Bucket.c \ +hammer/cartopol.c \ +hammer/cosh.c \ +hammer/counter.c \ +hammer/flush.c \ +hammer/forward.c \ +hammer/fromsymbol.c \ +hammer/mean.c \ +hammer/midiflush.c \ +hammer/midiformat.c \ +hammer/midiparse.c \ +hammer/next.c \ +hammer/onebang.c \ +hammer/Peak.c \ +hammer/poltocar.c \ +hammer/sinh.c \ +hammer/split.c \ +hammer/sustain.c \ +hammer/tanh.c \ +hammer/Trough.c \ +hammer/Uzi.c \ +hammer/xbendin.c \ +hammer/xbendin2.c \ +hammer/xbendout.c \ +hammer/xbendout2.c \ +hammer/xnotein.c \ +hammer/xnoteout.c + +HLOUD_SOURCES = \ +hammer/anal.c \ +hammer/bangbang.c \ +hammer/Borax.c \ +hammer/comment.c \ +hammer/cycle.c \ +hammer/decide.c \ +hammer/Decode.c \ +hammer/gate.c \ +hammer/Histo.c \ +hammer/maximum.c \ +hammer/minimum.c \ +hammer/spell.c \ +hammer/spray.c \ +hammer/sprintf.c \ +hammer/switch.c \ +hammer/TogEdge.c + +HFRAGILE_SOURCES = \ +hammer/grab.c \ +hammer/universal.c + +HGROW_SOURCES = \ +hammer/Append.c \ +hammer/bondo.c \ +hammer/buddy.c \ +hammer/Clip.c \ +hammer/funnel.c \ +hammer/iter.c \ +hammer/match.c \ +hammer/past.c \ +hammer/prepend.c \ +hammer/pv.c \ +hammer/speedlim.c \ +hammer/substitute.c \ +hammer/thresh.c \ +hammer/tosymbol.c \ +hammer/zl.c + +HFILE_SOURCES = \ +hammer/capture.c \ +hammer/coll.c + +HRAND_SOURCES = \ +hammer/drunk.c + +HRANDFILE_SOURCES = \ +hammer/prob.c + +HRANDGROW_SOURCES = \ +hammer/urn.c + +HTREE_SOURCES = \ +hammer/offer.c + +HTREEFILEVEFL_SOURCES = \ +hammer/funbuff.c + +HGUI_SOURCES = \ +hammer/active.c \ +hammer/mousefilter.c \ +hammer/MouseState.c + +HSEQ_SOURCES = \ +hammer/seq.c + +SPLAINNOTILDE_SOURCES = \ +sickle/linedrive.c + +SSIC_TILDE = $(TILDE) +SSIC_SOURCES = \ +sickle/abs.c \ +sickle/acos.c \ +sickle/acosh.c \ +sickle/allpass.c \ +sickle/asin.c \ +sickle/asinh.c \ +sickle/atan.c \ +sickle/atan2.c \ +sickle/atanh.c \ +sickle/average.c \ +sickle/avg.c \ +sickle/bitnot.c \ +sickle/bitshift.c \ +sickle/change.c \ +sickle/Clip.c \ +sickle/comb.c \ +sickle/cosh.c \ +sickle/cosx.c \ +sickle/count.c \ +sickle/delay.c \ +sickle/delta.c \ +sickle/deltaclip.c \ +sickle/edge.c \ +sickle/kink.c \ +sickle/log.c \ +sickle/minmax.c \ +sickle/peakamp.c \ +sickle/phasewrap.c \ +sickle/pow.c \ +sickle/rampsmooth.c \ +sickle/rand.c \ +sickle/sah.c \ +sickle/sinh.c \ +sickle/sinx.c \ +sickle/slide.c \ +sickle/Snapshot.c \ +sickle/spike.c \ +sickle/tanh.c \ +sickle/tanx.c \ +sickle/train.c \ +sickle/trapezoid.c \ +sickle/triangle.c \ +sickle/vectral.c + +SFORKY_TILDE = $(TILDE) +SFORKY_SOURCES = \ +sickle/bitand.c \ +sickle/bitor.c \ +sickle/bitxor.c + +SFRAGILE_TILDE = $(TILDE) +SFRAGILE_SOURCES = \ +sickle/cartopol.c \ +sickle/poltocar.c + +SGROW_TILDE = $(TILDE) +SGROW_SOURCES = \ +sickle/click.c \ +sickle/frameaccum.c \ +sickle/framedelta.c \ +sickle/Line.c + +SGROWFORKY_TILDE = $(TILDE) +SGROWFORKY_SOURCES = \ +sickle/Scope.c + +SVEFL_TILDE = $(TILDE) +SVEFL_SOURCES = \ +sickle/cycle.c + +SARSIC_TILDE = $(TILDE) +SARSIC_SOURCES = \ +sickle/index.c \ +sickle/lookup.c \ +sickle/peek.c \ +sickle/play.c \ +sickle/record.c \ +sickle/wave.c + +SFILE_TILDE = $(TILDE) +SFILE_SOURCES = \ +sickle/capture.c diff --git a/cyclone/build_counter b/cyclone/build_counter new file mode 100644 index 0000000..1e05d4b --- /dev/null +++ b/cyclone/build_counter @@ -0,0 +1,3 @@ +#define CYCLONE_VERSION "0.1" +#define CYCLONE_RELEASE "alpha" +#define CYCLONE_BUILD 42 diff --git a/cyclone/cyclone-all.exclude b/cyclone/cyclone-all.exclude new file mode 100644 index 0000000..8b8d91f --- /dev/null +++ b/cyclone/cyclone-all.exclude @@ -0,0 +1,9 @@ +*~ +*.o +*.gz +*.html +*.out +*/*/old +*/*/old/* +*/*/ref +*/*/ref/* diff --git a/cyclone/cyclone-shared.include b/cyclone/cyclone-shared.include new file mode 100644 index 0000000..49cc815 --- /dev/null +++ b/cyclone/cyclone-shared.include @@ -0,0 +1,35 @@ +shared/shared.c +shared/shared.h +shared/unstable/forky.c +shared/unstable/forky.h +shared/unstable/fragile.c +shared/unstable/fragile.h +shared/unstable/pd_imp.h +shared/common/grow.c +shared/common/grow.h +shared/common/loud.c +shared/common/loud.h +shared/common/binport.c +shared/common/binport.h +shared/common/port.c +shared/common/port.h +shared/common/rand.c +shared/common/rand.h +shared/common/vefl.c +shared/common/vefl.h +shared/common/sq.c +shared/common/sq.h +shared/common/bifi.c +shared/common/bifi.h +shared/common/mifi.c +shared/common/mifi.h +shared/hammer/file.c +shared/hammer/file.h +shared/hammer/gui.c +shared/hammer/gui.h +shared/hammer/tree.c +shared/hammer/tree.h +shared/sickle/sic.c +shared/sickle/sic.h +shared/sickle/arsic.c +shared/sickle/arsic.h diff --git a/cyclone/cyclone-test.exclude b/cyclone/cyclone-test.exclude new file mode 100644 index 0000000..ec84f87 --- /dev/null +++ b/cyclone/cyclone-test.exclude @@ -0,0 +1,4 @@ +*~ +import-result.pd +temporary +temporary/* diff --git a/cyclone/cyclone-vicious.exclude b/cyclone/cyclone-vicious.exclude new file mode 100644 index 0000000..5e5a82e --- /dev/null +++ b/cyclone/cyclone-vicious.exclude @@ -0,0 +1,3 @@ +*~ +old +old/* diff --git a/cyclone/hammer/Append.c b/cyclone/hammer/Append.c new file mode 100644 index 0000000..19978c7 --- /dev/null +++ b/cyclone/hammer/Append.c @@ -0,0 +1,207 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include +#include "m_pd.h" +#include "common/loud.h" +#include "common/grow.h" + +#define APPEND_INISIZE 32 /* LATER rethink */ +#define APPEND_MAXSIZE 256 + +typedef struct _append +{ + t_object x_ob; + int x_size; /* as allocated */ + int x_natoms; /* as used */ + t_atom *x_message; + t_atom *x_messbuf; + t_atom x_messini[APPEND_INISIZE]; + int x_entered; + int x_auxsize; + t_atom *x_auxbuf; +} t_append; + +static t_class *append_class; + +/* Usually a preallocation method is used, except in special cases of: + 1) reentrant output request, or 2) an output request which would cause + resizing to more than MAXSIZE (no such limit for a 'set' message). + In both special cases, a temporary output buffer is allocated. + A separately preallocated output buffer is not used, thus avoiding + memcpying of the stored message (a small performance gain when the + preallocation method is chosen). Instead, self-invoked 'set' + messages are postponed, using an auxiliary buffer. +*/ + +/* Any Append's output goes through outlet_anything() -> typedmess() */ + +static void append_setnatoms(t_append *x, int natoms) +{ + x->x_message = x->x_messbuf + x->x_size - natoms; + x->x_natoms = natoms; +} + +static void append_anything(t_append *x, t_symbol *s, int ac, t_atom *av) +{ + int reentered = x->x_entered; + int prealloc = !reentered; + int ntotal = x->x_natoms + ac; + t_atom *buf; + x->x_entered = 1; + if (prealloc && ntotal > x->x_size) + { + if (ntotal > APPEND_MAXSIZE) + prealloc = 0; + else + { + int nrequested = ntotal; + x->x_messbuf = grow_withtail(&nrequested, &x->x_natoms, + (char **)&x->x_message, + &x->x_size, x->x_messbuf, + APPEND_INISIZE, x->x_messini, + sizeof(*x->x_message)); + prealloc = (nrequested == ntotal); + } + } + if (prealloc) + { + buf = x->x_message - ac; + if (ac) + memcpy(buf, av, ac * sizeof(*buf)); + outlet_anything(((t_object *)x)->ob_outlet, s, ntotal, buf); + } + else + { + /* LATER consider using the stack if ntotal <= MAXSTACK */ + if (buf = getbytes(ntotal * sizeof(*buf))) + { + if (ac) + memcpy(buf, av, ac * sizeof(*buf)); + if (x->x_natoms) + memcpy(buf + ac, x->x_message, x->x_natoms * sizeof(*buf)); + outlet_anything(((t_object *)x)->ob_outlet, s, ntotal, buf); + freebytes(buf, ntotal * sizeof(*buf)); + } + } + if (!reentered) + { + x->x_entered = 0; + if (x->x_auxbuf) + { + if (x->x_auxsize <= x->x_size) + { + append_setnatoms(x, x->x_auxsize / 2); + memcpy(x->x_message, x->x_auxbuf + x->x_natoms, + x->x_natoms * sizeof(*x->x_message)); + freebytes(x->x_auxbuf, x->x_auxsize * sizeof(*x->x_auxbuf)); + } + else + { + if (x->x_messbuf != x->x_messini) + freebytes(x->x_messbuf, x->x_size * sizeof(*x->x_messbuf)); + x->x_size = x->x_auxsize; + x->x_messbuf = x->x_auxbuf; + append_setnatoms(x, x->x_auxsize / 2); + } + x->x_auxbuf = 0; + } + } +} + +static void append_bang(t_append *x) +{ + /* CHECKED: a nop */ +} + +static void append_float(t_append *x, t_float f) +{ + t_atom at; + SETFLOAT(&at, f); + append_anything(x, &s_list, 1, &at); /* CHECKED: converted to list */ +} + +/* CHECKED: incompatible -- LATER consider converting to anything */ +static void append_symbol(t_append *x, t_symbol *s) +{ + t_atom at; + SETSYMBOL(&at, s); + append_anything(x, &s_symbol, 1, &at); +} + +/* LATER gpointer */ + +static void append_set(t_append *x, t_symbol *s, int ac, t_atom *av) +{ + int newsize = ac * 2; + if (newsize > 0) + { + if (x->x_entered) + { + if (x->x_auxbuf) + { + loud_warning((t_pd *)x, "\'set\' message overridden"); + freebytes(x->x_auxbuf, x->x_auxsize * sizeof(*x->x_auxbuf)); + x->x_auxsize = 0; + } + if (x->x_auxbuf = getbytes(newsize * sizeof(*x->x_auxbuf))) + { + memcpy(x->x_auxbuf + ac, av, ac * sizeof(*x->x_auxbuf)); + x->x_auxsize = newsize; + } + } + else + { + t_atom *ap; + if (newsize > x->x_size) + { + int sz = newsize; + x->x_messbuf = grow_nodata(&sz, &x->x_size, x->x_messbuf, + APPEND_INISIZE, x->x_messini, + sizeof(*x->x_messbuf)); + if (sz != newsize) + ac = sz / 2; /* LATER rethink */ + } + append_setnatoms(x, ac); + ap = x->x_message; + while (ac--) *ap++ = *av++; + } + } +} + +static void append_free(t_append *x) +{ + if (x->x_messbuf != x->x_messini) + freebytes(x->x_messbuf, x->x_size * sizeof(*x->x_messbuf)); +} + +static void *append_new(t_symbol *s, int ac, t_atom *av) +{ + t_append *x = (t_append *)pd_new(append_class); + x->x_size = APPEND_INISIZE; + x->x_natoms = 0; + x->x_messbuf = x->x_messini; + x->x_auxbuf = 0; + x->x_entered = 0; + outlet_new((t_object *)x, &s_anything); + append_setnatoms(x, 0); + append_set(x, 0, ac, av); + return (x); +} + +void Append_setup(void) +{ + append_class = class_new(gensym("Append"), + (t_newmethod)append_new, + (t_method)append_free, + sizeof(t_append), 0, + A_GIMME, 0); + class_addbang(append_class, append_bang); + class_addfloat(append_class, append_float); + class_addsymbol(append_class, append_symbol); + class_addlist(append_class, append_anything); /* LATER rethink */ + class_addanything(append_class, append_anything); + class_addmethod(append_class, (t_method)append_set, + gensym("set"), A_GIMME, 0); +} diff --git a/cyclone/hammer/Borax.c b/cyclone/hammer/Borax.c new file mode 100644 index 0000000..26e0ef8 --- /dev/null +++ b/cyclone/hammer/Borax.c @@ -0,0 +1,177 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* The first version of this code was written by Olaf Matthes. + It was entirely reimplemented in the hope of adapting it to the + cyclone's guidelines. */ + +#include +#include "m_pd.h" +#include "common/loud.h" + +#define BORAX_MAXVOICES 128 /* CHECKME */ + +typedef struct _Borax_voice +{ + int v_index; /* free iff zero */ + double v_onset; + int v_nonsets; +} t_Borax_voice; + +typedef struct _Borax +{ + t_object x_ob; + int x_vel; /* CHECKME t_float controlled with floatinlet + (CHECKME the same in flush) */ + double x_onset; + int x_nonsets; + int x_ndurs; + int x_ndtimes; + int x_minindex; + int x_indices[BORAX_MAXVOICES]; /* 0 (free) or 1 (used) */ + int x_nvoices; + t_Borax_voice x_voices[BORAX_MAXVOICES]; + t_outlet *x_voiceout; + t_outlet *x_nvoicesout; + t_outlet *x_pitchout; + t_outlet *x_velout; + t_outlet *x_ndursout; + t_outlet *x_durout; + t_outlet *x_ndtimesout; + t_outlet *x_dtimeout; +} t_Borax; + +static t_class *Borax_class; + +static void Borax_delta(t_Borax *x) +{ + /* CHECKME first note */ + float dtime = clock_gettimesince(x->x_onset); /* CHECKME */ + outlet_float(x->x_dtimeout, dtime); + outlet_float(x->x_ndtimesout, ++x->x_ndtimes); /* CHECKME */ +} + +static void Borax_durout(t_Borax *x, int pitch) +{ + float dur = clock_gettimesince(x->x_voices[pitch].v_onset); /* CHECKME */ + outlet_float(x->x_durout, dur); + outlet_float(x->x_ndursout, ++x->x_ndurs); /* CHECKME */ +} + +static void Borax_float(t_Borax *x, t_float f) +{ + int pitch; + if (loud_checkint((t_pd *)x, f, &pitch, &s_float)) /* CHECKME */ + { + int index; + if (pitch < 0 || pitch >= BORAX_MAXVOICES) + { + /* CHECKME pitch range, complaints */ + return; + } + index = x->x_voices[pitch].v_index; + if (x->x_vel) + { + if (index) + return; /* CHECKME */ + x->x_indices[index = x->x_minindex] = 1; + while (x->x_indices[++x->x_minindex]); + index++; /* CHECKME one-based? */ + Borax_delta(x); + x->x_onset = clock_getlogicaltime(); /* CHECKME (in delta?) */ + x->x_voices[pitch].v_index = index; + x->x_voices[pitch].v_onset = x->x_onset; + x->x_voices[pitch].v_nonsets = ++x->x_nonsets; + x->x_nvoices++; + } + else + { + if (!index) + return; /* CHECKME */ + index--; + x->x_indices[index] = 0; + if (index < x->x_minindex) x->x_minindex = index; + index++; + Borax_durout(x, pitch); + x->x_voices[pitch].v_index = 0; + x->x_nvoices--; + } + outlet_float(x->x_velout, x->x_vel); + outlet_float(x->x_pitchout, pitch); + outlet_float(x->x_nvoicesout, x->x_nvoices); + outlet_float(x->x_voiceout, index); + outlet_float(((t_object *)x)->ob_outlet, x->x_voices[pitch].v_nonsets); + } +} + +static void Borax_ft1(t_Borax *x, t_floatarg f) +{ + x->x_vel = (int)f; /* CHECKME */ +} + +static void Borax_reset(t_Borax *x) +{ + x->x_vel = 0; + x->x_onset = clock_getlogicaltime(); + x->x_nonsets = x->x_ndurs = x->x_ndtimes = 0; + x->x_minindex = 0; + memset(x->x_indices, 0, sizeof(x->x_indices)); + x->x_nvoices = 0; + memset(x->x_voices, 0, sizeof(x->x_voices)); +} + +static void Borax_bang2(t_Borax *x) +{ + int pitch; + for (pitch = 0; pitch < BORAX_MAXVOICES; pitch++) + { + if (x->x_voices[pitch].v_index) + { + /* CHECKME counters, etc. */ + Borax_durout(x, pitch); + outlet_float(x->x_velout, 0); + outlet_float(x->x_pitchout, pitch); + outlet_float(x->x_nvoicesout, --x->x_nvoices); + outlet_float(x->x_voiceout, x->x_voices[pitch].v_index); + outlet_float(((t_object *)x)->ob_outlet, + x->x_voices[pitch].v_nonsets); + } + } + Borax_reset(x); +} + +/* CHECKME flush in a destructor */ + +static void *Borax_new(void) +{ + t_Borax *x = (t_Borax *)pd_new(Borax_class); + inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1")); + inlet_new((t_object *)x, (t_pd *)x, &s_bang, gensym("bang2")); + outlet_new((t_object *)x, &s_float); + x->x_voiceout = outlet_new((t_object *)x, &s_float); + x->x_nvoicesout = outlet_new((t_object *)x, &s_float); + x->x_pitchout = outlet_new((t_object *)x, &s_float); + x->x_velout = outlet_new((t_object *)x, &s_float); + x->x_ndursout = outlet_new((t_object *)x, &s_float); + x->x_durout = outlet_new((t_object *)x, &s_float); + x->x_ndtimesout = outlet_new((t_object *)x, &s_float); + x->x_dtimeout = outlet_new((t_object *)x, &s_float); + Borax_reset(x); + return (x); +} + +void Borax_setup(void) +{ + Borax_class = class_new(gensym("Borax"), + (t_newmethod)Borax_new, 0, + sizeof(t_Borax), 0, 0); + class_addfloat(Borax_class, Borax_float); + /* CHECKME list unfolding */ + class_addmethod(Borax_class, (t_method)Borax_ft1, + gensym("ft1"), A_FLOAT, 0); + class_addmethod(Borax_class, (t_method)Borax_bang2, + gensym("bang2"), 0); + class_addmethod(Borax_class, (t_method)Borax_delta, + gensym("delta"), 0); +} diff --git a/cyclone/hammer/Bucket.c b/cyclone/hammer/Bucket.c new file mode 100644 index 0000000..036f836 --- /dev/null +++ b/cyclone/hammer/Bucket.c @@ -0,0 +1,137 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* This is a modified version of Joseph A. Sarlo's code. + The most important changes are listed in "pd-lib-notes.txt" file. */ + +#include "m_pd.h" + +typedef struct _Bucket +{ + t_object x_ob; + int x_numbucks; + t_float *x_bucks; /* CHECKED: no limit */ + t_outlet **x_outs; + short int x_frozen; /* 0 for thawed, 1 for frozen */ + short int x_dir; /* 0 for L2R, 1 for R2L */ +} t_Bucket; + +static t_class *Bucket_class; + +static void Bucket_bang(t_Bucket *x) +{ + int i = x->x_numbucks; + /* CHECKED: outlets output in right-to-left order */ + while (i--) outlet_float(x->x_outs[i], x->x_bucks[i]); +} + +static void Bucket_float(t_Bucket *x, t_float val) +{ + int i; + + if (!x->x_frozen) + Bucket_bang(x); + if (!x->x_dir) + { + for (i = x->x_numbucks - 1; i > 0; i--) + x->x_bucks[i] = x->x_bucks[i - 1]; + x->x_bucks[0] = val; + } + else + { + for (i = 0; i < x->x_numbucks - 1; i++) + x->x_bucks[i] = x->x_bucks[i + 1]; + x->x_bucks[x->x_numbucks - 1] = val; + } +} + +static void Bucket_freeze(t_Bucket *x) +{ + x->x_frozen = 1; +} + +static void Bucket_thaw(t_Bucket *x) +{ + x->x_frozen = 0; +} + +static void Bucket_roll(t_Bucket *x) +{ + if (x->x_dir) + Bucket_float(x, x->x_bucks[0]); + else + Bucket_float(x, x->x_bucks[x->x_numbucks - 1]); +} + +static void Bucket_rtol(t_Bucket *x) +{ + x->x_dir = 1; +} + +static void Bucket_ltor(t_Bucket *x) +{ + x->x_dir = 0; +} + +static void Bucket_set(t_Bucket *x, t_floatarg f) +{ + int i = x->x_numbucks; + while (i--) x->x_bucks[i] = f; + if (!x->x_frozen) /* CHECKED */ + Bucket_bang(x); +} + +static void Bucket_free(t_Bucket *x) +{ + if (x->x_bucks) + freebytes(x->x_bucks, x->x_numbucks * sizeof(*x->x_bucks)); + if (x->x_outs) + freebytes(x->x_outs, x->x_numbucks * sizeof(*x->x_outs)); +} + +static void *Bucket_new(t_floatarg val) +{ + t_Bucket *x; + int i, nbucks = (int)val; + t_float *bucks; + t_outlet **outs; + if (nbucks < 1) + nbucks = 1; + if (!(bucks = (t_float *)getbytes(nbucks * sizeof(*bucks)))) + return (0); + if (!(outs = (t_outlet **)getbytes(nbucks * sizeof(*outs)))) + { + freebytes(bucks, nbucks * sizeof(*bucks)); + return (0); + } + x = (t_Bucket *)pd_new(Bucket_class); + x->x_numbucks = nbucks; + x->x_bucks = bucks; + x->x_outs = outs; + x->x_frozen = 0; + x->x_dir = 0; + while (nbucks--) *outs++ = outlet_new((t_object *)x, &s_float); + return (x); +} + +void Bucket_setup(void) +{ + Bucket_class = class_new(gensym("Bucket"), + (t_newmethod)Bucket_new, + (t_method)Bucket_free, + sizeof(t_Bucket), 0, A_DEFFLOAT, 0); + class_addbang(Bucket_class, Bucket_bang); + class_addfloat(Bucket_class, Bucket_float); + class_addmethod(Bucket_class, (t_method)Bucket_freeze, gensym("freeze"), 0); + class_addmethod(Bucket_class, (t_method)Bucket_thaw, gensym("thaw"), 0); + class_addmethod(Bucket_class, (t_method)Bucket_ltor, gensym("L2R"), 0); + class_addmethod(Bucket_class, (t_method)Bucket_rtol, gensym("R2L"), 0); + /* CHECKED (refman error) roll has no argument */ + class_addmethod(Bucket_class, (t_method)Bucket_roll, gensym("roll"), 0); + /* 3.5 additions */ + class_addmethod(Bucket_class, (t_method)Bucket_set, + gensym("set"), A_FLOAT, 0); + class_addmethod(Bucket_class, (t_method)Bucket_ltor, gensym("l2r"), 0); + class_addmethod(Bucket_class, (t_method)Bucket_rtol, gensym("r2l"), 0); +} diff --git a/cyclone/hammer/Clip.c b/cyclone/hammer/Clip.c new file mode 100644 index 0000000..a06d3a8 --- /dev/null +++ b/cyclone/hammer/Clip.c @@ -0,0 +1,149 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include +#include "m_pd.h" +#include "common/grow.h" + +#define CLIP_INISIZE 32 /* LATER rethink */ +#define CLIP_MAXSIZE 256 + +typedef struct _clip +{ + t_object x_ob; + float x_f1; + float x_f2; + int x_size; /* as allocated */ + t_atom *x_message; + t_atom x_messini[CLIP_INISIZE]; + int x_entered; +} t_clip; + +static t_class *clip_class; + +/* CHECKED case of f1 > f2: x <= f2 => f1, x > f2 => f2 + (Pd implementation of clip has it the other way around) */ +static void clip_float(t_clip *x, t_float f) +{ + outlet_float(((t_object *)x)->ob_outlet, + (f > x->x_f2 ? x->x_f2 : (f < x->x_f1 ? x->x_f1 : f))); +} + +static void clip_list(t_clip *x, t_symbol *s, int ac, t_atom *av) +{ + if (ac) + { + int docopy = 0; + int i; + t_atom *ap; + t_float f1 = x->x_f1; + t_float f2 = x->x_f2; + for (i = 0, ap = av; i < ac; i++, ap++) + { + t_float f; + if (ap->a_type == A_FLOAT) + f = ap->a_w.w_float; + else + { + docopy = 1; + /* CHECKED: symbols inside lists are converted to zeros */ + f = 0; + } + if (f < f1 || f > f2) docopy = 1; + } + if (docopy) + { + t_atom *buf; + t_atom *bp; + int reentered = x->x_entered; + int prealloc = !reentered; + x->x_entered = 1; + if (prealloc && ac > x->x_size) + { + if (ac > CLIP_MAXSIZE) + prealloc = 0; + else + x->x_message = grow_nodata(&ac, &x->x_size, x->x_message, + CLIP_INISIZE, x->x_messini, + sizeof(*x->x_message)); + } + if (prealloc) buf = x->x_message; + else + /* LATER consider using the stack if ntotal <= MAXSTACK */ + buf = getbytes(ac * sizeof(*buf)); + if (buf) + { + for (i = 0, ap = av, bp = buf; i < ac; i++, ap++, bp++) + { + t_float f = (ap->a_type == A_FLOAT ? ap->a_w.w_float : 0); + if (f < f1) + f = f1; + else if (f > f2) + f = f2; + SETFLOAT(bp, f); + } + outlet_list(((t_object *)x)->ob_outlet, &s_list, ac, buf); + if (buf != x->x_message) + freebytes(buf, ac * sizeof(*buf)); + } + if (!reentered) + { + x->x_entered = 0; + } + } + else outlet_list(((t_object *)x)->ob_outlet, &s_list, ac, av); + } +} + +static void clip_set(t_clip *x, t_symbol *s, int ac, t_atom *av) +{ + x->x_f1 = 0; + x->x_f2 = 0; + if (ac) /* CHECKED: 'set' without arguments sets both values to 0 */ + { + if (av->a_type == A_FLOAT) /* CHECKED: symbol is converted to 0 */ + x->x_f1 = av->a_w.w_float; + av++; + if (--ac) + { + if (av->a_type == A_FLOAT) + x->x_f2 = av->a_w.w_float; + } + else x->x_f2 = x->x_f1; /* CHECKED */ + } +} + +static void clip_free(t_clip *x) +{ + if (x->x_message != x->x_messini) + freebytes(x->x_message, x->x_size * sizeof(*x->x_message)); +} + +static void *clip_new(t_symbol *s, int ac, t_atom *av) +{ + t_clip *x = (t_clip *)pd_new(clip_class); + x->x_f1 = 0; + x->x_f2 = 0; + x->x_size = CLIP_INISIZE; + x->x_message = x->x_messini; + x->x_entered = 0; + floatinlet_new((t_object *)x, &x->x_f1); + floatinlet_new((t_object *)x, &x->x_f2); + outlet_new(&x->x_ob, &s_anything); + clip_set(x, 0, ac, av); + return (x); +} + +void Clip_setup(void) +{ + clip_class = class_new(gensym("Clip"), + (t_newmethod)clip_new, + (t_method)clip_free, + sizeof(t_clip), 0, + A_GIMME, 0); + class_addfloat(clip_class, clip_float); + class_addlist(clip_class, clip_list); + class_addmethod(clip_class, (t_method)clip_set, + gensym("set"), A_GIMME, 0); +} diff --git a/cyclone/hammer/Decode.c b/cyclone/hammer/Decode.c new file mode 100644 index 0000000..8317d7e --- /dev/null +++ b/cyclone/hammer/Decode.c @@ -0,0 +1,110 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* This is an entirely rewritten version of Joseph A. Sarlo's code. + The most important changes are listed in "pd-lib-notes.txt" file. */ + +#include "m_pd.h" +#include "common/loud.h" + +#define DECODE_MAXOUTS 8 /* CHECKED (does it make any sense?) */ +#define DECODE_DEFOUTS 1 + +typedef struct _Decode +{ + t_object x_ob; + int x_numouts; + int x_onout; + int x_allon; /* submaster switch */ + int x_alloff; /* master switch */ + t_outlet **x_outs; + t_outlet *x_outbuf[DECODE_MAXOUTS]; +} t_Decode; + +static t_class *Decode_class; + +/* CHECKED: all outlets deliver after any action */ +/* CHECKED: outlets output in right-to-left order */ + +static void Decode_deliver(t_Decode *x) +{ + int i = x->x_numouts; + if (x->x_alloff) + while (i--) outlet_float(x->x_outs[i], 0); + else if (x->x_allon) + while (i--) outlet_float(x->x_outs[i], 1); + else + while (i--) outlet_float(x->x_outs[i], (i == x->x_onout ? 1 : 0)); +} + +static void Decode_float(t_Decode *x, t_floatarg f) +{ + int val = (int)f; + /* CHECKED: out-of-range input is clipped, not ignored */ + if (val < 0) + val = 0; + else if (val >= x->x_numouts) + val = x->x_numouts - 1; + /* CHECKED: while in all-off mode, input is stored, not ignored */ + x->x_onout = val; + Decode_deliver(x); +} + +static void Decode_allon(t_Decode *x, t_floatarg f) +{ + x->x_allon = (f != 0); + Decode_deliver(x); +} + +static void Decode_alloff(t_Decode *x, t_floatarg f) +{ + x->x_alloff = (f != 0); + Decode_deliver(x); +} + +static void Decode_free(t_Decode *x) +{ + if (x->x_outs != x->x_outbuf) + freebytes(x->x_outs, x->x_numouts * sizeof(*x->x_outs)); +} + +static void *Decode_new(t_floatarg val) +{ + t_Decode *x; + int i, nouts = (int)val; + t_outlet **outs; + if (nouts < 1) + nouts = DECODE_DEFOUTS; + if (nouts > DECODE_MAXOUTS) + { + loud_incompatible_max(Decode_class, DECODE_MAXOUTS, "outlets"); + if (!(outs = (t_outlet **)getbytes(nouts * sizeof(*outs)))) + return (0); + } + else outs = 0; + x = (t_Decode *)pd_new(Decode_class); + x->x_numouts = nouts; + x->x_outs = (outs ? outs : x->x_outbuf); + x->x_onout = 0; + x->x_allon = 0; + x->x_alloff = 0; + inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1")); + inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft2")); + for (i = 0; i < nouts; i++) + x->x_outs[i] = outlet_new((t_object *)x, &s_float); + return (x); +} + +void Decode_setup(void) +{ + Decode_class = class_new(gensym("Decode"), + (t_newmethod)Decode_new, + (t_method)Decode_free, + sizeof(t_Decode), 0, A_DEFFLOAT, 0); + class_addfloat(Decode_class, Decode_float); + class_addmethod(Decode_class, (t_method)Decode_allon, + gensym("ft1"), A_FLOAT, 0); + class_addmethod(Decode_class, (t_method)Decode_alloff, + gensym("ft2"), A_FLOAT, 0); +} diff --git a/cyclone/hammer/Histo.c b/cyclone/hammer/Histo.c new file mode 100644 index 0000000..efb0deb --- /dev/null +++ b/cyclone/hammer/Histo.c @@ -0,0 +1,103 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* This is an entirely rewritten version of Joseph A. Sarlo's code. + The most important changes are listed in "pd-lib-notes.txt" file. */ + +#include "m_pd.h" +#include "common/loud.h" + +#define HISTO_DEFSIZE 128 + +typedef struct _Histo +{ + t_object x_ob; + int x_size; + unsigned *x_hist; /* LATER consider using 64 bits */ + int x_lastinput; + t_outlet *x_countout; +} t_Histo; + +static t_class *Histo_class; + +static void Histo_clear(t_Histo *x) +{ + int i = x->x_size; + while (i--) x->x_hist[i] = 0; + /* CHECKED: last input is kept */ +} + +static void Histo_doit(t_Histo *x, int val, int doincr) +{ + if (val >= 0 && val < x->x_size) + { + if (doincr) + { + /* CHECKED: only in-range numbers are stored */ + x->x_lastinput = val; + x->x_hist[val]++; + } + outlet_float(x->x_countout, x->x_hist[val]); + /* CHECKED: out-of-range numbers are never passed thru */ + outlet_float(((t_object *)x)->ob_outlet, val); + } +} + +static void Histo_bang(t_Histo *x) +{ + Histo_doit(x, x->x_lastinput, 0); +} + +static void Histo_float(t_Histo *x, t_floatarg f) +{ + int i; + if (loud_checkint((t_pd *)x, f, &i, &s_float)) /* CHECKED */ + Histo_doit(x, i, 1); +} + +static void Histo_ft1(t_Histo *x, t_floatarg f) +{ + /* CHECKED: floats are accepted in second inlet (truncated) */ + Histo_doit(x, (int)f, 0); +} + +static void Histo_free(t_Histo *x) +{ + if (x->x_hist) + freebytes(x->x_hist, x->x_size * sizeof(*x->x_hist)); +} + +static void *Histo_new(t_floatarg f) +{ + t_Histo *x; + int size = (int)f; + unsigned *hist; + if (size < 1) /* CHECKED: 1 is allowed */ + size = HISTO_DEFSIZE; + if (!(hist = (unsigned *)getbytes(size * sizeof(*hist)))) + return (0); + x = (t_Histo *)pd_new(Histo_class); + x->x_size = size; + x->x_hist = hist; + x->x_lastinput = 0; + inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1")); + outlet_new((t_object *)x, &s_float); + x->x_countout = outlet_new((t_object *)x, &s_float); + Histo_clear(x); + return (x); +} + +void Histo_setup(void) +{ + Histo_class = class_new(gensym("Histo"), + (t_newmethod)Histo_new, + (t_method)Histo_free, + sizeof(t_Histo), 0, A_DEFFLOAT, 0); + class_addbang(Histo_class, Histo_bang); + class_addfloat(Histo_class, Histo_float); + class_addmethod(Histo_class, (t_method)Histo_ft1, + gensym("ft1"), A_FLOAT, 0); + class_addmethod(Histo_class, (t_method)Histo_clear, + gensym("clear"), 0); +} diff --git a/cyclone/hammer/Makefile b/cyclone/hammer/Makefile new file mode 100644 index 0000000..54383c3 --- /dev/null +++ b/cyclone/hammer/Makefile @@ -0,0 +1,3 @@ +ROOT_DIR = ../.. +redefault: allhammers.c default +include $(ROOT_DIR)/Makefile.common diff --git a/cyclone/hammer/Makefile.objects b/cyclone/hammer/Makefile.objects new file mode 100644 index 0000000..0ac0a87 --- /dev/null +++ b/cyclone/hammer/Makefile.objects @@ -0,0 +1,14 @@ +SHARED_OBJECTS = \ +unstable/fragile.o \ +common/loud.o \ +common/grow.o \ +common/rand.o \ +common/vefl.o \ +common/sq.o \ +common/bifi.o \ +common/mifi.o \ +common/binport.o \ +common/port.o \ +hammer/file.o \ +hammer/gui.o \ +hammer/tree.o diff --git a/cyclone/hammer/Makefile.sources b/cyclone/hammer/Makefile.sources new file mode 100644 index 0000000..5df97f5 --- /dev/null +++ b/cyclone/hammer/Makefile.sources @@ -0,0 +1,80 @@ +CX_SOURCES = \ +hammer.c + +OTHER_SOURCES = \ +allhammers.c \ +testmess.c \ +accum.c \ +acos.c \ +active.c \ +anal.c \ +Append.c \ +asin.c \ +bangbang.c \ +bondo.c \ +Borax.c \ +Bucket.c \ +buddy.c \ +capture.c \ +cartopol.c \ +Clip.c \ +coll.c \ +comment.c \ +cosh.c \ +counter.c \ +cycle.c \ +decide.c \ +Decode.c \ +drunk.c \ +flush.c \ +forward.c \ +fromsymbol.c \ +funbuff.c \ +funnel.c \ +gate.c \ +grab.c \ +Histo.c \ +iter.c \ +match.c \ +maximum.c \ +mean.c \ +midiflush.c \ +midiformat.c \ +midiparse.c \ +minimum.c \ +mousefilter.c \ +MouseState.c \ +next.c \ +offer.c \ +onebang.c \ +past.c \ +Peak.c \ +poltocar.c \ +prepend.c \ +prob.c \ +pv.c \ +seq.c \ +sinh.c \ +speedlim.c \ +spell.c \ +split.c \ +spray.c \ +sprintf.c \ +substitute.c \ +sustain.c \ +switch.c \ +tanh.c \ +thresh.c \ +TogEdge.c \ +tosymbol.c \ +Trough.c \ +universal.c \ +urn.c \ +Uzi.c \ +xbendin.c \ +xbendin2.c \ +xbendout.c \ +xbendout2.c \ +xnotein.c \ +xnoteout.c \ +zl.c diff --git a/cyclone/hammer/MouseState.c b/cyclone/hammer/MouseState.c new file mode 100644 index 0000000..3b831bf --- /dev/null +++ b/cyclone/hammer/MouseState.c @@ -0,0 +1,153 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include "m_pd.h" +#include "hammer/gui.h" + +typedef struct _MouseState +{ + t_object x_ob; + int x_ispolling; + int x_wasbanged; + int x_waszeroed; + int x_hlast; + int x_vlast; + int x_hzero; + int x_vzero; + t_outlet *x_hposout; + t_outlet *x_vposout; + t_outlet *x_hdiffout; + t_outlet *x_vdiffout; +} t_MouseState; + +static t_class *MouseState_class; + +static void MouseState_anything(t_MouseState *x, + t_symbol *s, int ac, t_atom *av) +{ + /* dummy method, filtering out those messages from gui, + which are not handled explicitly */ +} + +static void MouseState_doup(t_MouseState *x, t_floatarg f) +{ + outlet_float(((t_object *)x)->ob_outlet, ((int)f ? 0 : 1)); +} + +static void MouseState_dobang(t_MouseState *x, t_floatarg f1, t_floatarg f2) +{ + if (x->x_wasbanged) + { + int h = (int)f1, v = (int)f2; + outlet_float(x->x_vdiffout, v - x->x_vlast); + outlet_float(x->x_hdiffout, h - x->x_hlast); + outlet_float(x->x_vposout, v - x->x_vzero); + outlet_float(x->x_hposout, h - x->x_hzero); + x->x_hlast = h; + x->x_vlast = v; + x->x_wasbanged = 0; + } +} + +static void MouseState_dozero(t_MouseState *x, t_floatarg f1, t_floatarg f2) +{ + if (x->x_waszeroed) + { + int h = (int)f1, v = (int)f2; + x->x_hzero = h; + x->x_vzero = v; + x->x_waszeroed = 0; + } +} + +static void MouseState_dopoll(t_MouseState *x, t_floatarg f1, t_floatarg f2) +{ + if (x->x_ispolling) + { + x->x_wasbanged = 1; + MouseState_dobang(x, f1, f2); + } +} + +static void MouseState_bang(t_MouseState *x) +{ + hammergui_mousexy(gensym("_bang")); + x->x_wasbanged = 1; +} + +static void MouseState_poll(t_MouseState *x) +{ + if (!x->x_ispolling) + { + x->x_ispolling = 1; + hammergui_startpolling((t_pd *)x); + } +} + +static void MouseState_nopoll(t_MouseState *x) +{ + if (x->x_ispolling) + { + x->x_ispolling = 0; + hammergui_stoppolling((t_pd *)x); + } +} + +static void MouseState_zero(t_MouseState *x) +{ + hammergui_mousexy(gensym("_zero")); + x->x_waszeroed = 1; +} + +static void MouseState_reset(t_MouseState *x) +{ + x->x_hzero = x->x_vzero = 0; +} + +static void MouseState_free(t_MouseState *x) +{ + MouseState_nopoll(x); + hammergui_unbindmouse((t_pd *)x); +} + +static void *MouseState_new(void) +{ + t_MouseState *x = (t_MouseState *)pd_new(MouseState_class); + x->x_ispolling = x->x_wasbanged = x->x_waszeroed = 0; + outlet_new((t_object *)x, &s_float); + x->x_hposout = outlet_new((t_object *)x, &s_float); + x->x_vposout = outlet_new((t_object *)x, &s_float); + x->x_hdiffout = outlet_new((t_object *)x, &s_float); + x->x_vdiffout = outlet_new((t_object *)x, &s_float); + hammergui_bindmouse((t_pd *)x); + hammergui_willpoll(); + MouseState_reset(x); + return (x); +} + +void MouseState_setup(void) +{ + MouseState_class = class_new(gensym("MouseState"), + (t_newmethod)MouseState_new, + (t_method)MouseState_free, + sizeof(t_MouseState), 0, 0); + class_addanything(MouseState_class, MouseState_anything); + class_addmethod(MouseState_class, (t_method)MouseState_doup, + gensym("_up"), A_FLOAT, 0); + class_addmethod(MouseState_class, (t_method)MouseState_dobang, + gensym("_bang"), A_FLOAT, A_FLOAT, 0); + class_addmethod(MouseState_class, (t_method)MouseState_dozero, + gensym("_zero"), A_FLOAT, A_FLOAT, 0); + class_addmethod(MouseState_class, (t_method)MouseState_dopoll, + gensym("_poll"), A_FLOAT, A_FLOAT, 0); + class_addbang(MouseState_class, MouseState_bang); + class_addmethod(MouseState_class, (t_method)MouseState_poll, + gensym("poll"), 0); + class_addmethod(MouseState_class, (t_method)MouseState_nopoll, + gensym("nopoll"), 0); + class_addmethod(MouseState_class, (t_method)MouseState_zero, + gensym("zero"), 0); + class_addmethod(MouseState_class, (t_method)MouseState_reset, + gensym("reset"), 0); +} diff --git a/cyclone/hammer/Peak.c b/cyclone/hammer/Peak.c new file mode 100644 index 0000000..6f7e30c --- /dev/null +++ b/cyclone/hammer/Peak.c @@ -0,0 +1,63 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include "m_pd.h" + +#define PEAK_INITIAL 0 + +typedef struct _Peak +{ + t_object x_ob; + t_float x_value; + t_outlet *x_out2; + t_outlet *x_out3; +} t_Peak; + +static t_class *Peak_class; + +static void Peak_bang(t_Peak *x) +{ + outlet_float(((t_object *)x)->ob_outlet, x->x_value); +} + +static void Peak_ft1(t_Peak *x, t_floatarg f) +{ + /* CHECKME loud_checkint */ + outlet_float(x->x_out3, 0); /* CHECKME */ + outlet_float(x->x_out2, 1); + outlet_float(((t_object *)x)->ob_outlet, x->x_value = f); +} + +static void Peak_float(t_Peak *x, t_float f) +{ + /* CHECKME loud_checkint */ + if (f > x->x_value) Peak_ft1(x, f); + else + { + outlet_float(x->x_out3, 1); + outlet_float(x->x_out2, 0); + } +} + +static void *Peak_new(t_floatarg f) +{ + t_Peak *x = (t_Peak *)pd_new(Peak_class); + x->x_value = PEAK_INITIAL; + inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1")); + outlet_new((t_object *)x, &s_float); + x->x_out2 = outlet_new((t_object *)x, &s_float); + x->x_out3 = outlet_new((t_object *)x, &s_float); + return (x); +} + +void Peak_setup(void) +{ + Peak_class = class_new(gensym("Peak"), + (t_newmethod)Peak_new, 0, + sizeof(t_Peak), 0, 0); + class_addbang(Peak_class, Peak_bang); + class_addfloat(Peak_class, Peak_float); + class_addmethod(Peak_class, (t_method)Peak_ft1, + gensym("ft1"), A_FLOAT, 0); +} diff --git a/cyclone/hammer/TogEdge.c b/cyclone/hammer/TogEdge.c new file mode 100644 index 0000000..79c26ec --- /dev/null +++ b/cyclone/hammer/TogEdge.c @@ -0,0 +1,71 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include "m_pd.h" +#include "common/loud.h" + +typedef struct _TogEdge +{ + t_object x_ob; + int x_wason; + t_outlet *x_out1; +} t_TogEdge; + +static t_class *TogEdge_class; + +static void TogEdge_bang(t_TogEdge *x) +{ + if (x->x_wason) + { + x->x_wason = 0; + outlet_bang(x->x_out1); + } + else + { + x->x_wason = 1; + outlet_bang(((t_object *)x)->ob_outlet); + } +} + +static void TogEdge_float(t_TogEdge *x, t_float f) +{ + int i; + if (loud_checkint((t_pd *)x, f, &i, &s_float)) /* CHECKED */ + { + if (x->x_wason) + { + if (!i) + { + x->x_wason = 0; + outlet_bang(x->x_out1); + } + } + else + { + if (i) + { + x->x_wason = 1; + outlet_bang(((t_object *)x)->ob_outlet); + } + } + } +} + +static void *TogEdge_new(void) +{ + t_TogEdge *x = (t_TogEdge *)pd_new(TogEdge_class); + x->x_wason = 0; /* CHECKED */ + outlet_new((t_object *)x, &s_bang); + x->x_out1 = outlet_new((t_object *)x, &s_bang); + return (x); +} + +void TogEdge_setup(void) +{ + TogEdge_class = class_new(gensym("TogEdge"), + (t_newmethod)TogEdge_new, 0, + sizeof(t_TogEdge), 0, 0); + class_addbang(TogEdge_class, TogEdge_bang); + class_addfloat(TogEdge_class, TogEdge_float); +} diff --git a/cyclone/hammer/Trough.c b/cyclone/hammer/Trough.c new file mode 100644 index 0000000..27b19ba --- /dev/null +++ b/cyclone/hammer/Trough.c @@ -0,0 +1,63 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include "m_pd.h" + +#define TROUGH_INITIAL 128 /* CHECKME */ + +typedef struct _Trough +{ + t_object x_ob; + t_float x_value; + t_outlet *x_out2; + t_outlet *x_out3; +} t_Trough; + +static t_class *Trough_class; + +static void Trough_bang(t_Trough *x) +{ + outlet_float(((t_object *)x)->ob_outlet, x->x_value); +} + +static void Trough_ft1(t_Trough *x, t_floatarg f) +{ + /* CHECKME loud_checkint */ + outlet_float(x->x_out3, 0); /* CHECKME */ + outlet_float(x->x_out2, 1); + outlet_float(((t_object *)x)->ob_outlet, x->x_value = f); +} + +static void Trough_float(t_Trough *x, t_float f) +{ + /* CHECKME loud_checkint */ + if (f < x->x_value) Trough_ft1(x, f); + else + { + outlet_float(x->x_out3, 1); + outlet_float(x->x_out2, 0); + } +} + +static void *Trough_new(t_floatarg f) +{ + t_Trough *x = (t_Trough *)pd_new(Trough_class); + x->x_value = TROUGH_INITIAL; + inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1")); + outlet_new((t_object *)x, &s_float); + x->x_out2 = outlet_new((t_object *)x, &s_float); + x->x_out3 = outlet_new((t_object *)x, &s_float); + return (x); +} + +void Trough_setup(void) +{ + Trough_class = class_new(gensym("Trough"), + (t_newmethod)Trough_new, 0, + sizeof(t_Trough), 0, 0); + class_addbang(Trough_class, Trough_bang); + class_addfloat(Trough_class, Trough_float); + class_addmethod(Trough_class, (t_method)Trough_ft1, + gensym("ft1"), A_FLOAT, 0); +} diff --git a/cyclone/hammer/Uzi.c b/cyclone/hammer/Uzi.c new file mode 100644 index 0000000..c773c6b --- /dev/null +++ b/cyclone/hammer/Uzi.c @@ -0,0 +1,108 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* CHECKME negative 'nbangs' value set during run-time */ + +#include "m_pd.h" + +typedef struct _Uzi +{ + t_object x_obj; + t_float x_nbangs; + int x_count; + int x_running; + t_outlet *x_out2; + t_outlet *x_out3; +} t_Uzi; + +static t_class *Uzi_class; + +#define UZI_RUNNING 1 +#define UZI_PAUSED 2 + +static void Uzi_dobang(t_Uzi *x) +{ + /* CHECKME reentrancy */ + if (!x->x_running) + { + int count, nbangs = (int)x->x_nbangs; + x->x_running = UZI_RUNNING; + for (count = x->x_count + 1; count <= nbangs; count++) + { + outlet_float(x->x_out3, count); + outlet_bang(((t_object *)x)->ob_outlet); + if (x->x_running == UZI_PAUSED) + { + /* CHECKED: carry bang not sent, even if this is last bang */ + x->x_count = count; + return; + } + } + /* CHECKED: carry bang sent also when there are no left-outlet bangs */ + /* CHECKED: sent after left outlet, not before */ + outlet_bang(x->x_out2); + x->x_count = 0; + x->x_running = 0; + } +} + +static void Uzi_bang(t_Uzi *x) +{ + /* CHECKED: always restarts (when paused too) */ + x->x_count = 0; + x->x_running = 0; + Uzi_dobang(x); +} + +static void Uzi_float(t_Uzi *x, t_float f) +{ + /* CHECKED: always sets a new value and restarts (when paused too) */ + x->x_nbangs = f; + Uzi_bang(x); +} + +/* CHECKED: 'pause, resume' (but not just 'resume') + sends a carry bang when not running (a bug?) */ +static void Uzi_pause(t_Uzi *x) +{ + if (!x->x_running) + x->x_count = (int)x->x_nbangs; /* bug emulation? */ + x->x_running = UZI_PAUSED; +} + +static void Uzi_resume(t_Uzi *x) +{ + if (x->x_running == UZI_PAUSED) + { + x->x_running = 0; + Uzi_dobang(x); + } +} + +static void *Uzi_new(t_floatarg f) +{ + t_Uzi *x = (t_Uzi *)pd_new(Uzi_class); + x->x_nbangs = (f > 1. ? f : 1.); + x->x_count = 0; + x->x_running = 0; + /* CHECKED: set when paused, but then 'resume' is blocked (a bug?) */ + floatinlet_new((t_object *)x, &x->x_nbangs); + outlet_new((t_object *)x, &s_bang); + x->x_out2 = outlet_new((t_object *)x, &s_bang); + x->x_out3 = outlet_new((t_object *)x, &s_float); + return (x); +} + +void Uzi_setup(void) +{ + Uzi_class = class_new(gensym("Uzi"), + (t_newmethod)Uzi_new, 0, + sizeof(t_Uzi), 0, A_DEFFLOAT, 0); + class_addbang(Uzi_class, Uzi_bang); + class_addfloat(Uzi_class, Uzi_float); + class_addmethod(Uzi_class, (t_method)Uzi_pause, gensym("pause"), 0); + class_addmethod(Uzi_class, (t_method)Uzi_pause, gensym("break"), 0); + class_addmethod(Uzi_class, (t_method)Uzi_resume, gensym("resume"), 0); + class_addmethod(Uzi_class, (t_method)Uzi_resume, gensym("continue"), 0); +} diff --git a/cyclone/hammer/accum.c b/cyclone/hammer/accum.c new file mode 100644 index 0000000..d266fb3 --- /dev/null +++ b/cyclone/hammer/accum.c @@ -0,0 +1,68 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* This is a slightly edited version of Joseph A. Sarlo's code. + The most important changes are listed in "pd-lib-notes.txt" file. */ + +#include "m_pd.h" + +typedef struct _accum +{ + t_object x_ob; + t_float x_total; +} t_accum; + +static t_class *accum_class; + +static void accum_set(t_accum *x, t_floatarg val) +{ + x->x_total = val; +} + +static void accum_bang(t_accum *x) +{ + outlet_float(((t_object *)x)->ob_outlet, x->x_total); +} + +static void accum_float(t_accum *x, t_floatarg val) +{ + /* LATER reconsider int/float dilemma */ + accum_set(x, val); + accum_bang(x); +} + +static void accum_add(t_accum *x, t_floatarg val) +{ + /* LATER reconsider int/float dilemma */ + x->x_total += val; +} + +static void accum_mult(t_accum *x, t_floatarg val) +{ + x->x_total *= val; +} + +static void *accum_new(t_floatarg val) +{ + t_accum *x = (t_accum *)pd_new(accum_class); + x->x_total = val; + inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1")); + inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft2")); + outlet_new((t_object *)x, &s_float); + return (x); +} + +void accum_setup(void) +{ + accum_class = class_new(gensym("accum"), (t_newmethod)accum_new, 0, + sizeof(t_accum), 0, A_DEFFLOAT, 0); + class_addbang(accum_class, accum_bang); + class_addfloat(accum_class, accum_float); + class_addmethod(accum_class, (t_method)accum_add, + gensym("ft1"), A_FLOAT, 0); + class_addmethod(accum_class, (t_method)accum_mult, + gensym("ft2"), A_FLOAT, 0); + class_addmethod(accum_class, (t_method)accum_set, + gensym("set"), A_FLOAT, 0); +} diff --git a/cyclone/hammer/acos.c b/cyclone/hammer/acos.c new file mode 100644 index 0000000..3f3abea --- /dev/null +++ b/cyclone/hammer/acos.c @@ -0,0 +1,48 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include +#include "m_pd.h" + +#if defined(NT) || defined(MACOSX) +/* cf pd/src/x_arithmetic.c */ +#define acosf acos +#endif + +typedef struct _acos +{ + t_object x_ob; + float x_value; +} t_acos; + +static t_class *acos_class; + +static void acos_bang(t_acos *x) +{ + outlet_float(((t_object *)x)->ob_outlet, x->x_value); +} + +static void acos_float(t_acos *x, t_float f) +{ + if (f < -1.0) f = -1.0; else if (f > 1.0) f = 1.0; /* CHECKME */ + outlet_float(((t_object *)x)->ob_outlet, x->x_value = acosf(f)); +} + +static void *acos_new(t_floatarg f) +{ + t_acos *x = (t_acos *)pd_new(acos_class); + if (f < -1.0) f = -1.0; else if (f > 1.0) f = 1.0; /* CHECKME */ + x->x_value = acosf(f); + outlet_new((t_object *)x, &s_float); + return (x); +} + +void acos_setup(void) +{ + acos_class = class_new(gensym("acos"), + (t_newmethod)acos_new, 0, + sizeof(t_acos), 0, A_DEFFLOAT, 0); + class_addbang(acos_class, acos_bang); + class_addfloat(acos_class, acos_float); +} diff --git a/cyclone/hammer/active.c b/cyclone/hammer/active.c new file mode 100644 index 0000000..9d10f80 --- /dev/null +++ b/cyclone/hammer/active.c @@ -0,0 +1,55 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include +#include "m_pd.h" +#include "hammer/gui.h" + +typedef struct _active +{ + t_object x_ob; + t_symbol *x_cvname; + int x_on; +} t_active; + +static t_class *active_class; + +static void active_dofocus(t_active *x, t_symbol *s, t_floatarg f) +{ + if ((int)f) + { + int on = (s == x->x_cvname); + if (on != x->x_on) + outlet_float(((t_object *)x)->ob_outlet, x->x_on = on); + } + else if (x->x_on && s == x->x_cvname) + outlet_float(((t_object *)x)->ob_outlet, x->x_on = 0); +} + +static void active_free(t_active *x) +{ + hammergui_unbindfocus((t_pd *)x); +} + +static void *active_new(void) +{ + t_active *x = (t_active *)pd_new(active_class); + char buf[32]; + sprintf(buf, ".x%x.c", (int)canvas_getcurrent()); + x->x_cvname = gensym(buf); + x->x_on = 0; + outlet_new((t_object *)x, &s_float); + hammergui_bindfocus((t_pd *)x); + return (x); +} + +void active_setup(void) +{ + active_class = class_new(gensym("active"), + (t_newmethod)active_new, + (t_method)active_free, + sizeof(t_active), CLASS_NOINLET, 0); + class_addmethod(active_class, (t_method)active_dofocus, + gensym("_focus"), A_SYMBOL, A_FLOAT, 0); +} diff --git a/cyclone/hammer/allhammers.c b/cyclone/hammer/allhammers.c new file mode 100644 index 0000000..e6d8235 --- /dev/null +++ b/cyclone/hammer/allhammers.c @@ -0,0 +1,160 @@ +// Do not edit this file, run "make" instead. + +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +void accum_setup(void); +void acos_setup(void); +void active_setup(void); +void anal_setup(void); +void Append_setup(void); +void asin_setup(void); +void bangbang_setup(void); +void bondo_setup(void); +void Borax_setup(void); +void Bucket_setup(void); +void buddy_setup(void); +void capture_setup(void); +void cartopol_setup(void); +void Clip_setup(void); +void coll_setup(void); +void comment_setup(void); +void cosh_setup(void); +void counter_setup(void); +void cycle_setup(void); +void decide_setup(void); +void Decode_setup(void); +void drunk_setup(void); +void flush_setup(void); +void forward_setup(void); +void fromsymbol_setup(void); +void funbuff_setup(void); +void funnel_setup(void); +void gate_setup(void); +void grab_setup(void); +void Histo_setup(void); +void iter_setup(void); +void match_setup(void); +void maximum_setup(void); +void mean_setup(void); +void midiflush_setup(void); +void midiformat_setup(void); +void midiparse_setup(void); +void minimum_setup(void); +void mousefilter_setup(void); +void MouseState_setup(void); +void next_setup(void); +void offer_setup(void); +void onebang_setup(void); +void past_setup(void); +void Peak_setup(void); +void poltocar_setup(void); +void prepend_setup(void); +void prob_setup(void); +void pv_setup(void); +void seq_setup(void); +void sinh_setup(void); +void speedlim_setup(void); +void spell_setup(void); +void split_setup(void); +void spray_setup(void); +void sprintf_setup(void); +void substitute_setup(void); +void sustain_setup(void); +void switch_setup(void); +void tanh_setup(void); +void testmess_setup(void); +void thresh_setup(void); +void TogEdge_setup(void); +void tosymbol_setup(void); +void Trough_setup(void); +void universal_setup(void); +void urn_setup(void); +void Uzi_setup(void); +void xbendin2_setup(void); +void xbendin_setup(void); +void xbendout2_setup(void); +void xbendout_setup(void); +void xnotein_setup(void); +void xnoteout_setup(void); +void zl_setup(void); + +void allhammers_setup(void) +{ + accum_setup(); + acos_setup(); + active_setup(); + anal_setup(); + Append_setup(); + asin_setup(); + bangbang_setup(); + bondo_setup(); + Borax_setup(); + Bucket_setup(); + buddy_setup(); + capture_setup(); + cartopol_setup(); + Clip_setup(); + coll_setup(); + comment_setup(); + cosh_setup(); + counter_setup(); + cycle_setup(); + decide_setup(); + Decode_setup(); + drunk_setup(); + flush_setup(); + forward_setup(); + fromsymbol_setup(); + funbuff_setup(); + funnel_setup(); + gate_setup(); + grab_setup(); + Histo_setup(); + iter_setup(); + match_setup(); + maximum_setup(); + mean_setup(); + midiflush_setup(); + midiformat_setup(); + midiparse_setup(); + minimum_setup(); + mousefilter_setup(); + MouseState_setup(); + next_setup(); + offer_setup(); + onebang_setup(); + past_setup(); + Peak_setup(); + poltocar_setup(); + prepend_setup(); + prob_setup(); + pv_setup(); + seq_setup(); + sinh_setup(); + speedlim_setup(); + spell_setup(); + split_setup(); + spray_setup(); + sprintf_setup(); + substitute_setup(); + sustain_setup(); + switch_setup(); + tanh_setup(); + testmess_setup(); + thresh_setup(); + TogEdge_setup(); + tosymbol_setup(); + Trough_setup(); + universal_setup(); + urn_setup(); + Uzi_setup(); + xbendin2_setup(); + xbendin_setup(); + xbendout2_setup(); + xbendout_setup(); + xnotein_setup(); + xnoteout_setup(); + zl_setup(); +} diff --git a/cyclone/hammer/anal.c b/cyclone/hammer/anal.c new file mode 100644 index 0000000..477eb20 --- /dev/null +++ b/cyclone/hammer/anal.c @@ -0,0 +1,108 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include +#include "m_pd.h" +#include "common/loud.h" + +#define ANAL_DEFSIZE 128 +#define ANAL_MAXSIZE 1024 + +typedef struct _anal +{ + t_object x_ob; + int x_value; /* negative, if initialized or reset */ + int x_size; + int x_bytesize; + int *x_table; + /* CHECKED: the 'weight' count is a signed short (2 bytes), + wrapping into negative domain without any warning. + LATER consider complaining at == SHRT_MAX. */ +} t_anal; + +static t_class *anal_class; + +static void anal_reset(t_anal *x) +{ + x->x_value = -1; +} + +static void anal_clear(t_anal *x) +{ + memset(x->x_table, 0, x->x_bytesize); +} + +static void anal_float(t_anal *x, t_float f) +{ + int value; + if (loud_checkint((t_pd *)x, f, &value, &s_float)) /* CHECKED */ + { + /* CHECKED: any input negative or >= size is ignored with an error + -- there is no output, and a previous state is kept. */ + if (value >= 0 && value < x->x_size) + { + if (x->x_value >= 0) + { + t_atom at[3]; + int ndx = x->x_value * x->x_size + value; + x->x_table[ndx]++; + SETFLOAT(at, x->x_value); + SETFLOAT(&at[1], value); + SETFLOAT(&at[2], x->x_table[ndx]); + outlet_list(((t_object *)x)->ob_outlet, &s_list, 3, at); + } + x->x_value = value; + } + else loud_error((t_pd *)x, "%d outside of table bounds", value); + } +} + +static void anal_free(t_anal *x) +{ + if (x->x_table) + freebytes(x->x_table, x->x_bytesize); +} + +static void *anal_new(t_floatarg f) +{ + t_anal *x; + int size = (int)f; + int bytesize; + int *table; + if (size < 1) + /* CHECKED: 1 is allowed (such an object rejects any nonzero input) */ + size = ANAL_DEFSIZE; + else if (size > ANAL_MAXSIZE) + { + /* CHECKED: */ + loud_warning(&anal_class, "size too large, using %d", ANAL_MAXSIZE); + size = ANAL_MAXSIZE; /* LATER switch into a 'sparse' mode */ + } + /* CHECKED: actually the bytesize is size * size * sizeof(short), + and it shows up in */ + bytesize = size * size * sizeof(*table); + if (!(table = (int *)getbytes(bytesize))) + return (0); + x = (t_anal *)pd_new(anal_class); + x->x_size = size; + x->x_bytesize = bytesize; + x->x_table = table; + outlet_new((t_object *)x, &s_list); + anal_reset(x); + anal_clear(x); + return (x); +} + +void anal_setup(void) +{ + anal_class = class_new(gensym("anal"), + (t_newmethod)anal_new, + (t_method)anal_free, + sizeof(t_anal), 0, A_DEFFLOAT, 0); + class_addfloat(anal_class, anal_float); + class_addmethod(anal_class, (t_method)anal_reset, + gensym("reset"), 0); + class_addmethod(anal_class, (t_method)anal_clear, + gensym("clear"), 0); +} diff --git a/cyclone/hammer/asin.c b/cyclone/hammer/asin.c new file mode 100644 index 0000000..0aa8db7 --- /dev/null +++ b/cyclone/hammer/asin.c @@ -0,0 +1,48 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include +#include "m_pd.h" + +#if defined(NT) || defined(MACOSX) +/* cf pd/src/x_arithmetic.c */ +#define asinf asin +#endif + +typedef struct _asin +{ + t_object x_ob; + float x_value; +} t_asin; + +static t_class *asin_class; + +static void asin_bang(t_asin *x) +{ + outlet_float(((t_object *)x)->ob_outlet, x->x_value); +} + +static void asin_float(t_asin *x, t_float f) +{ + if (f < -1.0) f = -1.0; else if (f > 1.0) f = 1.0; /* CHECKME */ + outlet_float(((t_object *)x)->ob_outlet, x->x_value = asinf(f)); +} + +static void *asin_new(t_floatarg f) +{ + t_asin *x = (t_asin *)pd_new(asin_class); + if (f < -1.0) f = -1.0; else if (f > 1.0) f = 1.0; /* CHECKME */ + x->x_value = asinf(f); + outlet_new((t_object *)x, &s_float); + return (x); +} + +void asin_setup(void) +{ + asin_class = class_new(gensym("asin"), + (t_newmethod)asin_new, 0, + sizeof(t_asin), 0, A_DEFFLOAT, 0); + class_addbang(asin_class, asin_bang); + class_addfloat(asin_class, asin_float); +} diff --git a/cyclone/hammer/bangbang.c b/cyclone/hammer/bangbang.c new file mode 100644 index 0000000..bebd26e --- /dev/null +++ b/cyclone/hammer/bangbang.c @@ -0,0 +1,73 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* This is a modified version of Joseph A. Sarlo's code. + The most important changes are listed in "pd-lib-notes.txt" file. */ + +#include "m_pd.h" +#include "common/loud.h" + +#define BANGBANG_MINOUTS 1 +#define BANGBANG_MAXOUTS 40 /* CHECKED (just clipped without warning) */ +#define BANGBANG_DEFOUTS 2 + +typedef struct _bangbang +{ + t_object x_ob; + int x_nouts; + t_outlet **x_outs; + t_outlet *x_outbuf[BANGBANG_DEFOUTS]; +} t_bangbang; + +static t_class *bangbang_class; + +static void bangbang_bang(t_bangbang *x) +{ + int i = x->x_nouts; + while (i--) outlet_bang(x->x_outs[i]); +} + +static void bangbang_anything(t_bangbang *x, t_symbol *s, int ac, t_atom *av) +{ + bangbang_bang(x); +} + +static void bangbang_free(t_bangbang *x) +{ + if (x->x_outs != x->x_outbuf) + freebytes(x->x_outs, x->x_nouts * sizeof(*x->x_outs)); +} + +static void *bangbang_new(t_floatarg val) +{ + t_bangbang *x; + int i, nouts = (int)val; + t_outlet **outs; + if (nouts < BANGBANG_MINOUTS) + nouts = BANGBANG_DEFOUTS; + if (nouts > BANGBANG_MAXOUTS) + loud_incompatible_max(bangbang_class, BANGBANG_MAXOUTS, "outlets"); + if (nouts > BANGBANG_DEFOUTS) + { + if (!(outs = (t_outlet **)getbytes(nouts * sizeof(*outs)))) + return (0); + } + else outs = 0; + x = (t_bangbang *)pd_new(bangbang_class); + x->x_nouts = nouts; + x->x_outs = (outs ? outs : x->x_outbuf); + for (i = 0; i < nouts; i++) + x->x_outs[i] = outlet_new((t_object *)x, &s_bang); + return (x); +} + +void bangbang_setup(void) +{ + bangbang_class = class_new(gensym("bangbang"), + (t_newmethod)bangbang_new, + (t_method)bangbang_free, + sizeof(t_bangbang), 0, A_DEFFLOAT, 0); + class_addbang(bangbang_class, bangbang_bang); + class_addanything(bangbang_class, bangbang_anything); +} diff --git a/cyclone/hammer/bondo.c b/cyclone/hammer/bondo.c new file mode 100644 index 0000000..2fcdce3 --- /dev/null +++ b/cyclone/hammer/bondo.c @@ -0,0 +1,394 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* LATER revisit buffer handling (maxsize, reentrancy) */ +/* LATER rethink handling of symbols */ + +/* CHECKED: if 'n' argument is given, then store whole messages, instead of + distributing atoms across successive slots. This is a new, buddy-like + behaviour. */ +/* CHECKED: without 'n' argument, 'symbol test' is parsed as two symbol atoms, + but 'float 1' (or 'list 1') as a single float. */ + +#include +#include "m_pd.h" +#include "common/grow.h" + +#define BONDO_MINSLOTS 2 +#define BONDO_INISIZE 4 /* LATER rethink (useful only in multiatom mode) */ + +typedef struct _bondo +{ + t_object x_ob; + t_float x_delay; + int x_multiatom; + int x_nslots; + int x_nproxies; /* as requested (and allocated) */ + t_pd **x_proxies; + t_outlet **x_outs; + t_clock *x_clock; +} t_bondo; + +typedef struct _bondo_proxy +{ + t_object p_ob; + t_bondo *p_master; + int p_id; + t_symbol *p_selector; + t_float p_float; + t_symbol *p_symbol; + t_gpointer *p_pointer; + int p_size; /* as allocated */ + int p_natoms; /* as used */ + t_atom *p_message; + t_atom p_messini[BONDO_INISIZE]; +} t_bondo_proxy; + +static t_class *bondo_class; +static t_class *bondo_proxy_class; + +static void bondo_doit(t_bondo *x) +{ + t_bondo_proxy **p = (t_bondo_proxy **)x->x_proxies; + int i = x->x_nslots; + p = (t_bondo_proxy **)x->x_proxies; + i = x->x_nslots; + while (i--) + { + t_symbol *s = p[i]->p_selector; + /* LATER consider complaining about extra arguments (CHECKED) */ + if (s == &s_bang) + outlet_bang(x->x_outs[i]); + else if (s == &s_float) + outlet_float(x->x_outs[i], p[i]->p_float); + else if (s == &s_symbol && p[i]->p_symbol) + { + /* LATER rethink */ + if (x->x_multiatom) + outlet_symbol(x->x_outs[i], p[i]->p_symbol); + else + outlet_anything(x->x_outs[i], p[i]->p_symbol, 0, 0); + } + else if (s == &s_pointer) + { + /* LATER */ + } + else if (s == &s_list) + outlet_list(x->x_outs[i], s, p[i]->p_natoms, p[i]->p_message); + else if (s) /* CHECKED: a slot may be inactive (in multiatom mode) */ + outlet_anything(x->x_outs[i], s, p[i]->p_natoms, p[i]->p_message); + } +} + +static void bondo_arm(t_bondo *x) +{ + if (x->x_delay <= 0) bondo_doit(x); + else clock_delay(x->x_clock, x->x_delay); +} + +static void bondo_proxy_bang(t_bondo_proxy *x) +{ + bondo_arm(x->p_master); /* CHECKED: bang in any inlet works in this way */ +} + +static void bondo_proxy_dofloat(t_bondo_proxy *x, t_float f, int doit) +{ + x->p_selector = &s_float; + x->p_float = f; + x->p_natoms = 0; /* defensive */ + if (doit) bondo_arm(x->p_master); +} + +static void bondo_proxy_float(t_bondo_proxy *x, t_float f) +{ + bondo_proxy_dofloat(x, f, 1); +} + +static void bondo_proxy_dosymbol(t_bondo_proxy *x, t_symbol *s, int doit) +{ + x->p_selector = &s_symbol; + x->p_symbol = s; + x->p_natoms = 0; /* defensive */ + if (doit) bondo_arm(x->p_master); +} + +static void bondo_proxy_symbol(t_bondo_proxy *x, t_symbol *s) +{ + bondo_proxy_dosymbol(x, s, 1); +} + +static void bondo_proxy_dopointer(t_bondo_proxy *x, t_gpointer *gp, int doit) +{ + x->p_selector = &s_pointer; + x->p_pointer = gp; + x->p_natoms = 0; /* defensive */ + if (doit) bondo_arm(x->p_master); +} + +static void bondo_proxy_pointer(t_bondo_proxy *x, t_gpointer *gp) +{ + bondo_proxy_dopointer(x, gp, 1); +} + +/* CHECKED: the slots fire in right-to-left order, + but they trigger only once (refman error) */ +static void bondo_distribute(t_bondo *x, int startid, + t_symbol *s, int ac, t_atom *av, int doit) +{ + t_atom *ap = av; + t_bondo_proxy **pp; + int id = startid + ac; + if (s) id++; + if (id > x->x_nslots) + id = x->x_nslots; + ap += id - startid; + pp = (t_bondo_proxy **)(x->x_proxies + id); + if (s) ap--; + while (ap-- > av) + { + pp--; + if (ap->a_type == A_FLOAT) + bondo_proxy_dofloat(*pp, ap->a_w.w_float, 0); + else if (ap->a_type == A_SYMBOL) + bondo_proxy_dosymbol(*pp, ap->a_w.w_symbol, 0); + else if (ap->a_type == A_POINTER) + bondo_proxy_dopointer(*pp, ap->a_w.w_gpointer, 0); + } + if (s) + bondo_proxy_dosymbol((t_bondo_proxy *)x->x_proxies[startid], s, 0); + if (doit) bondo_arm(x); +} + +static void bondo_proxy_domultiatom(t_bondo_proxy *x, + int ac, t_atom *av, int doit) +{ + if (ac > x->p_size) + { + /* LATER consider using BONDO_MAXSIZE (and warning if exceeded) */ + x->p_message = grow_nodata(&ac, &x->p_size, x->p_message, + BONDO_INISIZE, x->p_messini, + sizeof(*x->p_message)); + } + x->p_natoms = ac; + memcpy(x->p_message, av, ac * sizeof(*x->p_message)); + if (doit) bondo_arm(x->p_master); +} + +static void bondo_proxy_dolist(t_bondo_proxy *x, int ac, t_atom *av, int doit) +{ + if (x->p_master->x_multiatom) + { + x->p_selector = &s_list; + bondo_proxy_domultiatom(x, ac, av, doit); + } + else bondo_distribute(x->p_master, x->p_id, 0, ac, av, doit); +} + +static void bondo_proxy_list(t_bondo_proxy *x, + t_symbol *s, int ac, t_atom *av) +{ + bondo_proxy_dolist(x, ac, av, 1); +} + +static void bondo_proxy_doanything(t_bondo_proxy *x, + t_symbol *s, int ac, t_atom *av, int doit) +{ + if (x->p_master->x_multiatom) + { + /* LATER rethink and CHECKME */ + if (s == &s_symbol) + { + if (ac && av->a_type == A_SYMBOL) + bondo_proxy_dosymbol(x, av->a_w.w_symbol, doit); + else + bondo_proxy_dosymbol(x, &s_symbol, doit); + } + else + { + x->p_selector = s; + bondo_proxy_domultiatom(x, ac, av, doit); + } + } + else bondo_distribute(x->p_master, x->p_id, s, ac, av, doit); +} + +static void bondo_proxy_anything(t_bondo_proxy *x, + t_symbol *s, int ac, t_atom *av) +{ + bondo_proxy_doanything(x, s, ac, av, 1); +} + +static void bondo_proxy_set(t_bondo_proxy *x, + t_symbol *s, int ac, t_atom *av) +{ + if (ac) + { + if (av->a_type == A_FLOAT) + { + if (ac > 1) + bondo_proxy_dolist(x, ac, av, 0); + else + bondo_proxy_dofloat(x, av->a_w.w_float, 0); + } + else if (av->a_type == A_SYMBOL) + /* CHECKED: no tests for 'set float ...' and 'set list...' -- + the parsing is made in an output routine */ + bondo_proxy_doanything(x, av->a_w.w_symbol, ac-1, av+1, 0); + else if (av->a_type == A_POINTER) + bondo_proxy_dopointer(x, av->a_w.w_gpointer, 0); + } + /* CHECKED: 'set' without arguments makes a slot inactive, + if multiatom, but is ignored, if !multiatom */ + else if (x->p_master->x_multiatom) x->p_selector = 0; +} + +static void bondo_bang(t_bondo *x) +{ + bondo_proxy_bang((t_bondo_proxy *)x->x_proxies[0]); +} + +static void bondo_float(t_bondo *x, t_float f) +{ + bondo_proxy_dofloat((t_bondo_proxy *)x->x_proxies[0], f, 1); +} + +static void bondo_symbol(t_bondo *x, t_symbol *s) +{ + bondo_proxy_dosymbol((t_bondo_proxy *)x->x_proxies[0], s, 1); +} + +static void bondo_pointer(t_bondo *x, t_gpointer *gp) +{ + bondo_proxy_dopointer((t_bondo_proxy *)x->x_proxies[0], gp, 1); +} + +static void bondo_list(t_bondo *x, t_symbol *s, int ac, t_atom *av) +{ + bondo_proxy_dolist((t_bondo_proxy *)x->x_proxies[0], ac, av, 1); +} + +static void bondo_anything(t_bondo *x, t_symbol *s, int ac, t_atom *av) +{ + bondo_proxy_doanything((t_bondo_proxy *)x->x_proxies[0], s, ac, av, 1); +} + +static void bondo_set(t_bondo *x, t_symbol *s, int ac, t_atom *av) +{ + bondo_proxy_set((t_bondo_proxy *)x->x_proxies[0], s, ac, av); +} + +static void bondo_free(t_bondo *x) +{ + if (x->x_clock) clock_free(x->x_clock); + if (x->x_proxies) + { + int i = x->x_nslots; + while (i--) + { + t_bondo_proxy *y = (t_bondo_proxy *)x->x_proxies[i]; + if (y->p_message != y->p_messini) + freebytes(y->p_message, y->p_size * sizeof(*y->p_message)); + pd_free((t_pd *)y); + } + freebytes(x->x_proxies, x->x_nproxies * sizeof(*x->x_proxies)); + } + if (x->x_outs) + freebytes(x->x_outs, x->x_nslots * sizeof(*x->x_outs)); +} + +static void *bondo_new(t_symbol *s, int ac, t_atom *av) +{ + t_bondo *x; + int i, nslots, nproxies = BONDO_MINSLOTS; + int multiatom = 0; + t_float delay = 0; + t_pd **proxies; + t_outlet **outs; + i = 0; + while (ac--) + { + /* CHECKED: no warnings */ + if (av->a_type == A_FLOAT) + { + if (i == 0) + nproxies = (int)av->a_w.w_float; + else if (i == 1) + delay = av->a_w.w_float; + i++; + } + else if (av->a_type == A_SYMBOL) + { + if (av->a_w.w_symbol == gensym("n")) multiatom = 1; + /* CHECKED: 'n' has to be the last argument given; + the arguments after any symbol are silently ignored -- + LATER decide if we should comply and break here */ + } + av++; + } + if (nproxies < BONDO_MINSLOTS) + nproxies = BONDO_MINSLOTS; + if (!(proxies = (t_pd **)getbytes(nproxies * sizeof(*proxies)))) + return (0); + for (nslots = 0; nslots < nproxies; nslots++) + if (!(proxies[nslots] = pd_new(bondo_proxy_class))) break; + if (nslots < BONDO_MINSLOTS + || !(outs = (t_outlet **)getbytes(nslots * sizeof(*outs)))) + { + i = nslots; + while (i--) pd_free(proxies[i]); + freebytes(proxies, nproxies * sizeof(*proxies)); + return (0); + } + x = (t_bondo *)pd_new(bondo_class); + x->x_delay = delay; + x->x_multiatom = multiatom; + x->x_nslots = nslots; + x->x_nproxies = nproxies; + x->x_proxies = proxies; + x->x_outs = outs; + for (i = 0; i < nslots; i++) + { + t_bondo_proxy *y = (t_bondo_proxy *)proxies[i]; + y->p_master = x; + y->p_id = i; + y->p_selector = &s_float; /* CHECKED: it is so in multiatom mode too */ + y->p_float = 0; + y->p_symbol = 0; + y->p_pointer = 0; + y->p_size = BONDO_INISIZE; + y->p_natoms = 0; + y->p_message = y->p_messini; + if (i) inlet_new((t_object *)x, (t_pd *)y, 0, 0); + x->x_outs[i] = outlet_new((t_object *)x, &s_anything); + } + x->x_clock = clock_new(x, (t_method)bondo_doit); + return (x); +} + +void bondo_setup(void) +{ + bondo_class = class_new(gensym("bondo"), + (t_newmethod)bondo_new, + (t_method)bondo_free, + sizeof(t_bondo), 0, A_GIMME, 0); + class_addbang(bondo_class, bondo_bang); + class_addfloat(bondo_class, bondo_float); + class_addsymbol(bondo_class, bondo_symbol); + class_addpointer(bondo_class, bondo_pointer); + class_addlist(bondo_class, bondo_list); + class_addanything(bondo_class, bondo_anything); + class_addmethod(bondo_class, (t_method)bondo_set, + gensym("set"), A_GIMME, 0); + bondo_proxy_class = class_new(gensym("_bondo_proxy"), 0, 0, + sizeof(t_bondo_proxy), + CLASS_PD | CLASS_NOINLET, 0); + class_addbang(bondo_proxy_class, bondo_proxy_bang); + class_addfloat(bondo_proxy_class, bondo_proxy_float); + class_addsymbol(bondo_proxy_class, bondo_proxy_symbol); + class_addpointer(bondo_proxy_class, bondo_proxy_pointer); + class_addlist(bondo_proxy_class, bondo_proxy_list); + class_addanything(bondo_proxy_class, bondo_proxy_anything); + class_addmethod(bondo_proxy_class, (t_method)bondo_proxy_set, + gensym("set"), A_GIMME, 0); +} diff --git a/cyclone/hammer/buddy.c b/cyclone/hammer/buddy.c new file mode 100644 index 0000000..f272739 --- /dev/null +++ b/cyclone/hammer/buddy.c @@ -0,0 +1,253 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* LATER compare with buddy.c from max sdk */ +/* LATER revisit buffer handling (maxsize, reentrancy) */ + +#include +#include "m_pd.h" +#include "common/grow.h" + +#define BUDDY_MINSLOTS 2 +#define BUDDY_INISIZE 4 /* LATER rethink */ + +typedef struct _buddy +{ + t_object x_ob; + int x_nslots; + int x_nproxies; /* as requested (and allocated) */ + t_pd **x_proxies; + t_outlet **x_outs; +} t_buddy; + +typedef struct _buddy_proxy +{ + t_object p_ob; + t_buddy *p_master; + t_symbol *p_selector; + t_float p_float; + t_symbol *p_symbol; + t_gpointer *p_pointer; + int p_size; /* as allocated */ + int p_natoms; /* as used */ + t_atom *p_message; + t_atom p_messini[BUDDY_INISIZE]; +} t_buddy_proxy; + +static t_class *buddy_class; +static t_class *buddy_proxy_class; + +static void buddy_clear(t_buddy *x) +{ + t_buddy_proxy **p = (t_buddy_proxy **)x->x_proxies; + int i = x->x_nslots; + while (i--) + { + (*p)->p_selector = 0; + (*p++)->p_natoms = 0; /* defensive */ + } +} + +static void buddy_check(t_buddy *x) +{ + t_buddy_proxy **p = (t_buddy_proxy **)x->x_proxies; + int i = x->x_nslots; + while (i--) + if (!(*p++)->p_selector) + return; + p = (t_buddy_proxy **)x->x_proxies; + i = x->x_nslots; + while (i--) + { + t_symbol *s = p[i]->p_selector; + if (s == &s_bang) + outlet_bang(x->x_outs[i]); + else if (s == &s_float) + outlet_float(x->x_outs[i], p[i]->p_float); + else if (s == &s_symbol && p[i]->p_symbol) + outlet_symbol(x->x_outs[i], p[i]->p_symbol); + else if (s == &s_pointer) + { + /* LATER */ + } + else if (s == &s_list) + outlet_list(x->x_outs[i], s, p[i]->p_natoms, p[i]->p_message); + else if (s) + outlet_anything(x->x_outs[i], s, p[i]->p_natoms, p[i]->p_message); + } + buddy_clear(x); +} + +static void buddy_proxy_bang(t_buddy_proxy *x) +{ + x->p_selector = &s_bang; + x->p_natoms = 0; /* defensive */ + buddy_check(x->p_master); +} + +static void buddy_proxy_float(t_buddy_proxy *x, t_float f) +{ + x->p_selector = &s_float; + x->p_float = f; + x->p_natoms = 0; /* defensive */ + buddy_check(x->p_master); +} + +static void buddy_proxy_symbol(t_buddy_proxy *x, t_symbol *s) +{ + x->p_selector = &s_symbol; + x->p_symbol = s; + x->p_natoms = 0; /* defensive */ + buddy_check(x->p_master); +} + +static void buddy_proxy_pointer(t_buddy_proxy *x, t_gpointer *gp) +{ + x->p_selector = &s_pointer; + x->p_pointer = gp; + x->p_natoms = 0; /* defensive */ + buddy_check(x->p_master); +} + +static void buddy_proxy_domessage(t_buddy_proxy *x, int ac, t_atom *av) +{ + if (ac > x->p_size) + { + /* LATER consider using BUDDY_MAXSIZE (and warning if exceeded) */ + x->p_message = grow_nodata(&ac, &x->p_size, x->p_message, + BUDDY_INISIZE, x->p_messini, + sizeof(*x->p_message)); + } + x->p_natoms = ac; + memcpy(x->p_message, av, ac * sizeof(*x->p_message)); + buddy_check(x->p_master); +} + +static void buddy_proxy_list(t_buddy_proxy *x, + t_symbol *s, int ac, t_atom *av) +{ + x->p_selector = &s_list; /* LATER rethink */ + buddy_proxy_domessage(x, ac, av); +} + +static void buddy_proxy_anything(t_buddy_proxy *x, + t_symbol *s, int ac, t_atom *av) +{ + x->p_selector = s; /* LATER rethink */ + buddy_proxy_domessage(x, ac, av); +} + +static void buddy_bang(t_buddy *x) +{ + buddy_proxy_bang((t_buddy_proxy *)x->x_proxies[0]); +} + +static void buddy_float(t_buddy *x, t_float f) +{ + buddy_proxy_float((t_buddy_proxy *)x->x_proxies[0], f); +} + +static void buddy_symbol(t_buddy *x, t_symbol *s) +{ + buddy_proxy_symbol((t_buddy_proxy *)x->x_proxies[0], s); +} + +static void buddy_pointer(t_buddy *x, t_gpointer *gp) +{ + buddy_proxy_pointer((t_buddy_proxy *)x->x_proxies[0], gp); +} + +static void buddy_list(t_buddy *x, t_symbol *s, int ac, t_atom *av) +{ + buddy_proxy_list((t_buddy_proxy *)x->x_proxies[0], s, ac, av); +} + +static void buddy_anything(t_buddy *x, t_symbol *s, int ac, t_atom *av) +{ + buddy_proxy_anything((t_buddy_proxy *)x->x_proxies[0], s, ac, av); +} + +static void buddy_free(t_buddy *x) +{ + if (x->x_proxies) + { + int i = x->x_nslots; + while (i--) + { + t_buddy_proxy *y = (t_buddy_proxy *)x->x_proxies[i]; + if (y->p_message != y->p_messini) + freebytes(y->p_message, y->p_size * sizeof(*y->p_message)); + pd_free((t_pd *)y); + } + freebytes(x->x_proxies, x->x_nproxies * sizeof(*x->x_proxies)); + } + if (x->x_outs) + freebytes(x->x_outs, x->x_nslots * sizeof(*x->x_outs)); +} + +static void *buddy_new(t_floatarg f) +{ + t_buddy *x; + int i, nslots, nproxies = (int)f; + t_pd **proxies; + t_outlet **outs; + if (nproxies < BUDDY_MINSLOTS) + nproxies = BUDDY_MINSLOTS; + if (!(proxies = (t_pd **)getbytes(nproxies * sizeof(*proxies)))) + return (0); + for (nslots = 0; nslots < nproxies; nslots++) + if (!(proxies[nslots] = pd_new(buddy_proxy_class))) break; + if (nslots < BUDDY_MINSLOTS + || !(outs = (t_outlet **)getbytes(nslots * sizeof(*outs)))) + { + int i = nslots; + while (i--) pd_free(proxies[i]); + freebytes(proxies, nproxies * sizeof(*proxies)); + return (0); + } + x = (t_buddy *)pd_new(buddy_class); + x->x_nslots = nslots; + x->x_nproxies = nproxies; + x->x_proxies = proxies; + x->x_outs = outs; + for (i = 0; i < nslots; i++) + { + t_buddy_proxy *y = (t_buddy_proxy *)proxies[i]; + y->p_master = x; + y->p_selector = 0; + y->p_float = 0; + y->p_symbol = 0; + y->p_pointer = 0; + y->p_size = BUDDY_INISIZE; + y->p_natoms = 0; + y->p_message = y->p_messini; + if (i) inlet_new((t_object *)x, (t_pd *)y, 0, 0); + x->x_outs[i] = outlet_new((t_object *)x, &s_anything); + } + return (x); +} + +void buddy_setup(void) +{ + buddy_class = class_new(gensym("buddy"), + (t_newmethod)buddy_new, + (t_method)buddy_free, + sizeof(t_buddy), 0, A_DEFFLOAT, 0); + class_addbang(buddy_class, buddy_bang); + class_addfloat(buddy_class, buddy_float); + class_addsymbol(buddy_class, buddy_symbol); + class_addpointer(buddy_class, buddy_pointer); + class_addlist(buddy_class, buddy_list); + class_addanything(buddy_class, buddy_anything); + class_addmethod(buddy_class, (t_method)buddy_clear, gensym("clear"), 0); + buddy_proxy_class = class_new(gensym("_buddy_proxy"), 0, 0, + sizeof(t_buddy_proxy), + CLASS_PD | CLASS_NOINLET, 0); + class_addbang(buddy_proxy_class, buddy_proxy_bang); + class_addfloat(buddy_proxy_class, buddy_proxy_float); + class_addsymbol(buddy_proxy_class, buddy_proxy_symbol); + class_addpointer(buddy_proxy_class, buddy_proxy_pointer); + class_addlist(buddy_proxy_class, buddy_proxy_list); + class_addanything(buddy_proxy_class, buddy_proxy_anything); +} diff --git a/cyclone/hammer/capture.c b/cyclone/hammer/capture.c new file mode 100644 index 0000000..b36c421 --- /dev/null +++ b/cyclone/hammer/capture.c @@ -0,0 +1,291 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include +#include "m_pd.h" +#include "common/loud.h" +#include "hammer/file.h" + +#define CAPTURE_DEFSIZE 512 + +typedef struct _capture +{ + t_object x_ob; + t_canvas *x_canvas; + char x_intmode; /* if nonzero ('x' or 'm') floats are ignored */ + float *x_buffer; + int x_bufsize; + int x_count; + int x_head; + t_hammerfile *x_filehandle; +} t_capture; + +static t_class *capture_class; + +static void capture_float(t_capture *x, t_float f) +{ + if (x->x_intmode && f != (int)f) /* CHECKME float */ + return; + x->x_buffer[x->x_head++] = f; + if (x->x_head >= x->x_bufsize) + x->x_head = 0; + if (x->x_count < x->x_bufsize) + x->x_count++; +} + +static void capture_list(t_capture *x, t_symbol *s, int ac, t_atom *av) +{ + while (ac--) + { + if (av->a_type == A_FLOAT) /* CHECKME */ + capture_float(x, av->a_w.w_float); + av++; + } +} + +static void capture_clear(t_capture *x) +{ + x->x_count = 0; + x->x_head = 0; +} + +static void capture_count(t_capture *x) +{ + post("capture: %d items received", /* CHECKED */ + x->x_count); /* CHECKED incompatible (4.07 seems buggy here) */ +} + +static void capture_dump(t_capture *x) +{ + int count = x->x_count; + if (count < x->x_bufsize) + { + float *bp = x->x_buffer; + while (count--) + outlet_float(((t_object *)x)->ob_outlet, *bp++); + } + else + { + float *bp = x->x_buffer + x->x_head; + count = x->x_bufsize - x->x_head; + while (count--) + outlet_float(((t_object *)x)->ob_outlet, *bp++); + bp = x->x_buffer; + count = x->x_head; + while (count--) + outlet_float(((t_object *)x)->ob_outlet, *bp++); + } +} + +static int capture_formatint(int i, char *buf, int col, + int maxcol, char *fmt) +{ + char *bp = buf; + int cnt = 0; + if (col > 0) + *bp++ = ' ', cnt++; + cnt += sprintf(bp, fmt, i); + if (col + cnt > maxcol) + buf[0] = '\n', col = cnt; + else + col += cnt; + return (col); +} + +static int capture_formatfloat(float f, char *buf, int col, + int maxcol, char *fmt) +{ + char *bp = buf; + int cnt = 0; + if (col > 0) + *bp++ = ' ', cnt++; + cnt += sprintf(bp, fmt, f); + if (col + cnt > maxcol) + buf[0] = '\n', col = cnt; + else + col += cnt; + return (col); +} + +static int capture_formatnumber(t_capture *x, float f, char *buf, + int col, int maxcol) +{ + char intmode = x->x_intmode; + if (intmode == 'm') + intmode = (f < 128 && f > -128 ? 'd' : 'x'); /* CHECKME */ + if (intmode == 'x') + col = capture_formatint((int)f, buf, col, maxcol, "%x"); + else if (intmode) + col = capture_formatint((int)f, buf, col, maxcol, "%d"); + else + col = capture_formatfloat(f, buf, col, maxcol, "%g"); + return (col); +} + +static int capture_writefloat(t_capture *x, float f, char *buf, int col, + FILE *fp) +{ + /* CHECKED no linebreaks (FIXME) */ + col = capture_formatnumber(x, f, buf, col, 80); + return (fputs(buf, fp) < 0 ? -1 : col); +} + +static void capture_dowrite(t_capture *x, t_symbol *fn) +{ + FILE *fp = 0; + int count = x->x_count; + char buf[MAXPDSTRING]; + canvas_makefilename(x->x_canvas, fn->s_name, buf, MAXPDSTRING); + if (fp = fopen(buf, "w")) /* LATER ask if overwriting, CHECKED */ + { + int col = 0; + if (count < x->x_bufsize) + { + float *bp = x->x_buffer; + while (count--) + if ((col = capture_writefloat(x, *bp++, buf, col, fp)) < 0) + goto fail; + } + else + { + float *bp = x->x_buffer + x->x_head; + count = x->x_bufsize - x->x_head; + while (count--) + if ((col = capture_writefloat(x, *bp++, buf, col, fp)) < 0) + goto fail; + bp = x->x_buffer; + count = x->x_head; + while (count--) + if ((col = capture_writefloat(x, *bp++, buf, col, fp)) < 0) + goto fail; + } + if (col) fputc('\n', fp); + fclose(fp); + return; + } +fail: + if (fp) fclose(fp); + loud_syserror((t_pd *)x, 0); +} + +static void capture_writehook(t_pd *z, t_symbol *fn, int ac, t_atom *av) +{ + capture_dowrite((t_capture *)z, fn); +} + +static void capture_write(t_capture *x, t_symbol *s) +{ + if (s && s != &s_) + capture_dowrite(x, s); + else + hammerpanel_save(x->x_filehandle, 0, 0); +} + +static int capture_appendfloat(t_capture *x, float f, char *buf, int col) +{ + /* CHECKED 80 columns */ + col = capture_formatnumber(x, f, buf, col, 80); + hammereditor_append(x->x_filehandle, buf); + return (col); +} + +static void capture_open(t_capture *x) +{ + int count = x->x_count; + char buf[MAXPDSTRING]; + hammereditor_open(x->x_filehandle, "t_capture"); /* CHECKED */ + if (count < x->x_bufsize) + { + float *bp = x->x_buffer; + int col = 0; + while (count--) + col = capture_appendfloat(x, *bp++, buf, col); + } + else + { + float *bp = x->x_buffer + x->x_head; + int col = 0; + count = x->x_bufsize - x->x_head; + while (count--) + col = capture_appendfloat(x, *bp++, buf, col); + bp = x->x_buffer; + count = x->x_head; + while (count--) + col = capture_appendfloat(x, *bp++, buf, col); + } +} + +/* CHECKED without asking and storing the changes */ +static void capture_wclose(t_capture *x) +{ + hammereditor_close(x->x_filehandle, 0); +} + +static void capture_click(t_capture *x, t_floatarg xpos, t_floatarg ypos, + t_floatarg shift, t_floatarg ctrl, t_floatarg alt) +{ + capture_open(x); +} + +static void capture_free(t_capture *x) +{ + hammerfile_free(x->x_filehandle); + if (x->x_buffer) + freebytes(x->x_buffer, x->x_bufsize * sizeof(*x->x_buffer)); +} + +static void *capture_new(t_symbol *s, t_floatarg f) +{ + t_capture *x = 0; + float *buffer; + int bufsize = (int)f; /* CHECKME */ + if (bufsize <= 0) /* CHECKME */ + bufsize = CAPTURE_DEFSIZE; + if (buffer = getbytes(bufsize * sizeof(*buffer))) + { + x = (t_capture *)pd_new(capture_class); + x->x_canvas = canvas_getcurrent(); + if (s && s != &s_) + { + if (s == gensym("x")) + x->x_intmode = 'x'; + else if (s == gensym("m")) + x->x_intmode = 'm'; + else + x->x_intmode = 'd'; /* ignore floats */ + } + x->x_buffer = buffer; + x->x_bufsize = bufsize; + outlet_new((t_object *)x, &s_float); + x->x_filehandle = hammerfile_new((t_pd *)x, 0, 0, capture_writehook, 0); + capture_clear(x); + } + return (x); +} + +void capture_setup(void) +{ + capture_class = class_new(gensym("capture"), + (t_newmethod)capture_new, + (t_method)capture_free, + sizeof(t_capture), 0, A_DEFFLOAT, A_DEFSYM, 0); + class_addfloat(capture_class, capture_float); + class_addlist(capture_class, capture_list); + class_addmethod(capture_class, (t_method)capture_clear, + gensym("clear"), 0); + class_addmethod(capture_class, (t_method)capture_count, + gensym("count"), 0); + class_addmethod(capture_class, (t_method)capture_dump, + gensym("dump"), 0); + class_addmethod(capture_class, (t_method)capture_write, + gensym("write"), A_DEFSYM, 0); + class_addmethod(capture_class, (t_method)capture_open, + gensym("open"), 0); + class_addmethod(capture_class, (t_method)capture_wclose, + gensym("wclose"), 0); + class_addmethod(capture_class, (t_method)capture_click, + gensym("click"), + A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); + hammerfile_setup(capture_class, 0); +} diff --git a/cyclone/hammer/cartopol.c b/cyclone/hammer/cartopol.c new file mode 100644 index 0000000..4200686 --- /dev/null +++ b/cyclone/hammer/cartopol.c @@ -0,0 +1,44 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include +#include "m_pd.h" + +#if defined(NT) || defined(MACOSX) +/* cf pd/src/x_arithmetic.c */ +#define atan2f atan2 +#define hypotf hypot +#endif + +typedef struct _cartopol +{ + t_object x_ob; + t_float x_imag; + t_outlet *x_out2; +} t_cartopol; + +static t_class *cartopol_class; + +static void cartopol_float(t_cartopol *x, t_float f) +{ + outlet_float(x->x_out2, atan2f(x->x_imag, f)); + outlet_float(((t_object *)x)->ob_outlet, hypotf(f, x->x_imag)); +} + +static void *cartopol_new(void) +{ + t_cartopol *x = (t_cartopol *)pd_new(cartopol_class); + floatinlet_new((t_object *)x, &x->x_imag); + outlet_new((t_object *)x, &s_float); + x->x_out2 = outlet_new((t_object *)x, &s_float); + return (x); +} + +void cartopol_setup(void) +{ + cartopol_class = class_new(gensym("cartopol"), + (t_newmethod)cartopol_new, 0, + sizeof(t_cartopol), 0, 0); + class_addfloat(cartopol_class, cartopol_float); +} diff --git a/cyclone/hammer/coll.c b/cyclone/hammer/coll.c new file mode 100644 index 0000000..c4a3388 --- /dev/null +++ b/cyclone/hammer/coll.c @@ -0,0 +1,1597 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include +#include +#include "m_pd.h" +#include "g_canvas.h" +#include "common/loud.h" +#include "hammer/file.h" + +/* FIXME sort crashes after (corrupt?) transfers from the editor */ +/* LATER make sure that ``reentrancy protection hack'' is really working... */ +/* CHECKME default fname for 'write' -- c_filename, x_name, nothing? */ + +#define COLL_DEBUG + +typedef struct _collelem +{ + int e_hasnumkey; + int e_numkey; + t_symbol *e_symkey; + struct _collelem *e_prev; + struct _collelem *e_next; + int e_size; + t_atom *e_data; +} t_collelem; + +typedef struct _collcommon +{ + t_pd c_pd; + struct _coll *c_refs; /* used in read-banging and dirty flag handling */ + int c_embedflag; /* common field (CHECKED in 'TEXT') */ + int c_loading; + int c_relinked; + int c_selfmodified; + int c_entered; /* a counter, LATER rethink */ + t_symbol *c_filename; + t_canvas *c_lastcanvas; + t_hammerfile *c_filehandle; + t_collelem *c_first; + t_collelem *c_last; + t_collelem *c_ahead; + t_collelem *c_back; +} t_collcommon; + +typedef struct _coll +{ + t_object x_ob; + t_canvas *x_canvas; + t_symbol *x_name; + t_collcommon *x_common; + t_hammerfile *x_filehandle; + t_outlet *x_keyout; + t_outlet *x_filebangout; + t_outlet *x_dumpbangout; + struct _coll *x_next; +} t_coll; + +static t_class *coll_class; +static t_class *collcommon_class; + +static t_collelem *collelem_new(int ac, t_atom *av, int *np, t_symbol *s) +{ + t_collelem *ep = (t_collelem *)getbytes(sizeof(*ep)); + if (ep->e_hasnumkey = (np != 0)) + ep->e_numkey = *np; + ep->e_symkey = s; + ep->e_prev = ep->e_next = 0; + if (ep->e_size = ac) + { + t_atom *ap = getbytes(ac * sizeof(*ap)); + ep->e_data = ap; + if (av) while (ac--) + *ap++ = *av++; + else while (ac--) + { + SETFLOAT(ap, 0); + ap++; + } + } + else ep->e_data = 0; + return (ep); +} + +static void collelem_free(t_collelem *ep) +{ + if (ep->e_data) + freebytes(ep->e_data, ep->e_size * sizeof(*ep->e_data)); + freebytes(ep, sizeof(*ep)); +} + +/* CHECKME again... apparently c74 is not able to fix this for good */ +/* result: 1 for ep1 < ep2, otherwise 0 (symbols are less then floats) */ +static int collelem_less(t_collelem *ep1, t_collelem *ep2, int ndx) +{ + if (ndx < 0) + { + if (ep1->e_symkey) + return (ep2->e_symkey ? + strcmp(ep1->e_symkey->s_name, + ep2->e_symkey->s_name) < 0 + : 1); /* CHECKED incompatible with 4.07, but consistent */ + else if (ep2->e_symkey) + return (0); /* CHECKED incompatible with 4.07, but consistent */ + else + return (ep1->e_numkey < ep2->e_numkey); /* CHECKED in 4.07 */ + } + else + { + t_atom *ap1 = (ndx < ep1->e_size ? + ep1->e_data + ndx : ep1->e_data + ep1->e_size - 1); + t_atom *ap2 = (ndx < ep2->e_size ? + ep2->e_data + ndx : ep2->e_data + ep2->e_size - 1); + if (ap1->a_type == A_FLOAT) + { + if (ap2->a_type == A_FLOAT) + return (ap1->a_w.w_float < ap2->a_w.w_float); + else if (ap2->a_type == A_SYMBOL) + return (0); + else + return (1); + } + else if (ap1->a_type == A_SYMBOL) + { + if (ap2->a_type == A_FLOAT) + return (1); + else if (ap2->a_type == A_SYMBOL) + return (strcmp(ap1->a_w.w_symbol->s_name, + ap2->a_w.w_symbol->s_name) < 0); + else + return (1); + } + else + return (0); + } +} + +static void collelem_post(t_collelem *ep) +{ + if (ep->e_hasnumkey && ep->e_symkey) + startpost("%d %s:", ep->e_numkey, ep->e_symkey->s_name); + else if (ep->e_hasnumkey) + startpost("%d:", ep->e_numkey); + else if (ep->e_symkey) + startpost("%s:", ep->e_symkey->s_name); + else bug("collcommon_post"); + postatom(ep->e_size, ep->e_data); + endpost(); +} + +static void collcommon_post(t_collcommon *cc) +{ + t_collelem *ep; + for (ep = cc->c_first; ep; ep = ep->e_next) collelem_post(ep); +} + +static t_collelem *collcommon_numkey(t_collcommon *cc, int numkey) +{ + t_collelem *ep; + for (ep = cc->c_first; ep; ep = ep->e_next) + if (ep->e_hasnumkey && ep->e_numkey == numkey) + return (ep); + return (0); +} + +static t_collelem *collcommon_symkey(t_collcommon *cc, t_symbol *symkey) +{ + t_collelem *ep; + for (ep = cc->c_first; ep; ep = ep->e_next) + if (ep->e_symkey == symkey) + return (ep); + return (0); +} + +static void collcommon_takeout(t_collcommon *cc, t_collelem *ep) +{ + if (ep->e_prev) + ep->e_prev->e_next = ep->e_next; + else + cc->c_first = ep->e_next; + if (ep->e_next) + ep->e_next->e_prev = ep->e_prev; + else + cc->c_last = ep->e_prev; + if (cc->c_ahead == ep) + cc->c_ahead = ep->e_next; + if (cc->c_back == ep) + cc->c_back = ep->e_prev; +} + +static void collcommon_modified(t_collcommon *cc, int relinked) +{ + if (cc->c_loading) + return; + if (relinked) + { + cc->c_relinked = 1; + } + if (cc->c_embedflag) + { + t_coll *x; + for (x = cc->c_refs; x; x = x->x_next) + if (x->x_canvas && glist_isvisible(x->x_canvas)) + canvas_dirty(x->x_canvas, 1); + } +} + +/* atomic collcommon modifiers: clearall, remove, replace, + putbefore, putafter, swaplinks, swapkeys, changesymkey, renumber, sort */ + +static void collcommon_clearall(t_collcommon *cc) +{ + if (cc->c_first) + { + t_collelem *ep1 = cc->c_first, *ep2; + do + { + ep2 = ep1->e_next; + collelem_free(ep1); + } + while (ep1 = ep2); + cc->c_first = cc->c_last = 0; + cc->c_ahead = cc->c_back = 0; + collcommon_modified(cc, 1); + } +} + +static void collcommon_remove(t_collcommon *cc, t_collelem *ep) +{ + collcommon_takeout(cc, ep); + collelem_free(ep); + collcommon_modified(cc, 1); +} + +static void collcommon_replace(t_collcommon *cc, t_collelem *ep, + int ac, t_atom *av, int *np, t_symbol *s) +{ + if (ep->e_hasnumkey = (np != 0)) + ep->e_numkey = *np; + ep->e_symkey = s; + if (ac) + { + int i = ac; + t_atom *ap; + if (ep->e_data) + { + if (ep->e_size != ac) + ap = resizebytes(ep->e_data, + ep->e_size * sizeof(*ap), ac * sizeof(*ap)); + else ap = ep->e_data; + } + else + ap = getbytes(ac * sizeof(*ap)); + ep->e_data = ap; + if (av) while (i --) + *ap++ = *av++; + else while (i --) + { + SETFLOAT(ap, 0); + ap++; + } + } + else + { + if (ep->e_data) + freebytes(ep->e_data, ep->e_size * sizeof(*ep->e_data)); + ep->e_data = 0; + } + ep->e_size = ac; + collcommon_modified(cc, 0); +} + +static void collcommon_putbefore(t_collcommon *cc, + t_collelem *ep, t_collelem *next) +{ + if (next) + { + ep->e_next = next; + if (ep->e_prev = next->e_prev) + ep->e_prev->e_next = ep; + else + cc->c_first = ep; + next->e_prev = ep; + } + else if (cc->c_first || cc->c_last) + bug("collcommon_putbefore"); + else + cc->c_first = cc->c_last = ep; + collcommon_modified(cc, 1); +} + +static void collcommon_putafter(t_collcommon *cc, + t_collelem *ep, t_collelem *prev) +{ + if (prev) + { + ep->e_prev = prev; + if (ep->e_next = prev->e_next) + ep->e_next->e_prev = ep; + else + cc->c_last = ep; + prev->e_next = ep; + } + else if (cc->c_first || cc->c_last) + bug("collcommon_putafter"); + else + cc->c_first = cc->c_last = ep; + collcommon_modified(cc, 1); +} + +/* LATER consider making it faster, if there is a real need. + Now called only in the sort routine, once per sort. */ +static void collcommon_swaplinks(t_collcommon *cc, + t_collelem *ep1, t_collelem *ep2) +{ + if (ep1 != ep2) + { + t_collelem *prev1 = ep1->e_prev, *prev2 = ep2->e_prev; + if (prev1 == ep2) + { + collcommon_takeout(cc, ep2); + collcommon_putafter(cc, ep2, ep1); + } + else if (prev2 == ep1) + { + collcommon_takeout(cc, ep1); + collcommon_putafter(cc, ep1, ep2); + } + else if (prev1) + { + if (prev2) + { + collcommon_takeout(cc, ep1); + collcommon_takeout(cc, ep2); + collcommon_putafter(cc, ep1, prev2); + collcommon_putafter(cc, ep2, prev1); + } + else + { + t_collelem *next2 = ep2->e_next; + collcommon_takeout(cc, ep1); + collcommon_takeout(cc, ep2); + collcommon_putbefore(cc, ep1, next2); + collcommon_putafter(cc, ep2, prev1); + } + } + else if (prev2) + { + t_collelem *next1 = ep1->e_next; + collcommon_takeout(cc, ep1); + collcommon_takeout(cc, ep2); + collcommon_putafter(cc, ep1, prev2); + collcommon_putbefore(cc, ep2, next1); + } + else bug("collcommon_swaplinks"); + } +} + +static void collcommon_swapkeys(t_collcommon *cc, + t_collelem *ep1, t_collelem *ep2) +{ + int hasnumkey = ep2->e_hasnumkey, numkey = ep2->e_numkey; + t_symbol *symkey = ep2->e_symkey; + ep2->e_hasnumkey = ep1->e_hasnumkey; + ep2->e_numkey = ep1->e_numkey; + ep2->e_symkey = ep1->e_symkey; + ep1->e_hasnumkey = hasnumkey; + ep1->e_numkey = numkey; + ep1->e_symkey = symkey; + collcommon_modified(cc, 0); +} + +static void collcommon_changesymkey(t_collcommon *cc, + t_collelem *ep, t_symbol *s) +{ + ep->e_symkey = s; + collcommon_modified(cc, 0); +} + +static void collcommon_renumber(t_collcommon *cc, int startkey) +{ + t_collelem *ep; + for (ep = cc->c_first; ep; ep = ep->e_next) + if (ep->e_hasnumkey) + ep->e_numkey = startkey++; + collcommon_modified(cc, 0); +} + +/* LATER choose a better algo, after coll's storage structures stabilize. + Note, that even the simple insertion sort below (n-square) might prove + better for dlls, than theoretically efficient algo (nlogn) which requires + random access emulation. Avoiding recursion is not a bad idea, too. */ +static void collcommon_sort(t_collcommon *cc, int asc, int ndx) +{ + t_collelem *min = cc->c_first; + t_collelem *ep; + if (min && (ep = min->e_next)) + { + cc->c_loading = 1; + /* search for a sentinel element */ + do + if (collelem_less(ep, min, ndx) == asc) min = ep; + while (ep = ep->e_next); + /* prepend it */ + collcommon_swaplinks(cc, cc->c_first, min); + /* sort */ + ep = min->e_next->e_next; + while (ep) + { + t_collelem *next = ep->e_next; + for (min = ep->e_prev; + collelem_less(ep, min, ndx) == asc; + min = min->e_prev); + if (ep != min->e_next) + { + collcommon_takeout(cc, ep); + collcommon_putafter(cc, ep, min); + } + ep = next; + } + cc->c_loading = 0; + collcommon_modified(cc, 1); + } +} + +static void collcommon_adddata(t_collcommon *cc, t_collelem *ep, + int ac, t_atom *av) +{ + if (ac) + { + t_atom *ap; + int newsize = ep->e_size + ac; + if (ep->e_data) + ap = resizebytes(ep->e_data, + ep->e_size * sizeof(*ap), newsize * sizeof(*ap)); + else + { + ep->e_size = 0; /* redundant, hopefully */ + ap = getbytes(newsize * sizeof(*ap)); + } + ep->e_data = ap; + ap += ep->e_size; + if (av) while (ac--) + *ap++ = *av++; + else while (ac--) + { + SETFLOAT(ap, 0); + ap++; + } + ep->e_size = newsize; + collcommon_modified(cc, 0); + } +} + +static t_collelem *collcommon_tonumkey(t_collcommon *cc, int numkey, + int ac, t_atom *av, int replace) +{ + t_collelem *old = collcommon_numkey(cc, numkey), *new; + if (old && replace) + collcommon_replace(cc, new = old, ac, av, &numkey, 0); + else + { + new = collelem_new(ac, av, &numkey, 0); + if (old) + { + collcommon_putbefore(cc, new, old); + do + if (old->e_hasnumkey) old->e_numkey++; /* LATER rethink */ + while (old = old->e_next); + } + else + { + int closestkey = 0; /* LATER rethink */ + t_collelem *closest = 0, *ep; + for (ep = cc->c_first; ep; ep = ep->e_next) + { + if (ep->e_hasnumkey) + { + if (numkey >= closestkey && numkey <= ep->e_numkey) + { + collcommon_putbefore(cc, new, ep); + break; + } + closestkey = ep->e_numkey; + } + closest = ep; + } + if (!ep) + { + if (numkey <= closestkey) + collcommon_putbefore(cc, new, closest); + else + collcommon_putafter(cc, new, closest); + } + } + } + return (new); +} + +static t_collelem *collcommon_tosymkey(t_collcommon *cc, t_symbol *symkey, + int ac, t_atom *av, int replace) +{ + t_collelem *old = collcommon_symkey(cc, symkey), *new; + if (old && replace) + collcommon_replace(cc, new = old, ac, av, 0, symkey); + else + collcommon_putafter(cc, new = collelem_new(ac, av, 0, symkey), + cc->c_last); + return (new); +} + +static int collcommon_fromlist(t_collcommon *cc, int ac, t_atom *av) +{ + int hasnumkey = 0, numkey; + t_symbol *symkey = 0; + int size = 0; + t_atom *data = 0; + int nlines = 0; + cc->c_loading = 1; + collcommon_clearall(cc); + while (ac--) + { + if (data) + { + if (av->a_type == A_SEMI) + { + t_collelem *ep = collelem_new(size, data, + hasnumkey ? &numkey : 0, symkey); + collcommon_putafter(cc, ep, cc->c_last); + hasnumkey = 0; + symkey = 0; + data = 0; + nlines++; + } + if (av->a_type == A_COMMA) + { + /* CHECKED rejecting a comma */ + collcommon_clearall(cc); /* LATER rethink */ + cc->c_loading = 0; + return (-nlines); + } + else size++; + } + else if (av->a_type == A_COMMA) + { + size = 0; + data = av + 1; + } + else if (av->a_type == A_SYMBOL) + symkey = av->a_w.w_symbol; + else if (av->a_type == A_FLOAT && + loud_checkint(0, av->a_w.w_float, &numkey, 0)) + hasnumkey = 1; + else + { + loud_error(0, "coll: bad atom"); + collcommon_clearall(cc); /* LATER rethink */ + cc->c_loading = 0; + return (-nlines); + } + av++; + } + if (data) + { + loud_error(0, "coll: incomplete"); + collcommon_clearall(cc); /* LATER rethink */ + cc->c_loading = 0; + return (-nlines); + } + cc->c_loading = 0; + return (nlines); +} + +static int collcommon_frombinbuf(t_collcommon *cc, t_binbuf *bb) +{ + return (collcommon_fromlist(cc, binbuf_getnatom(bb), binbuf_getvec(bb))); +} + +static void collcommon_doread(t_collcommon *cc, t_symbol *fn, t_canvas *cv) +{ + t_binbuf *bb; + int ac; + t_atom *av; + char buf[MAXPDSTRING]; + if (!fn && !(fn = cc->c_filename)) /* !fn: 'readagain' */ + return; + if (cv || (cv = cc->c_lastcanvas)) /* !cv: 'read' w/o arg, 'readagain' */ + canvas_makefilename(cv, fn->s_name, buf, MAXPDSTRING); + else + { + strncpy(buf, fn->s_name, MAXPDSTRING); + buf[MAXPDSTRING-1] = 0; + } + if (!cc->c_refs) + { + /* loading during object creation -- + avoid binbuf_read()'s complaints, LATER rethink */ + FILE *fp; + char fname[MAXPDSTRING]; + sys_bashfilename(buf, fname); + if (!(fp = fopen(fname, "r"))) + { + loud_warning(&coll_class, "no coll file '%s'", fname); + return; + } + fclose(fp); + } + bb = binbuf_new(); + if (binbuf_read(bb, buf, "", 0)) + loud_error(0, "coll: error reading text file '%s'", fn->s_name); + else + { + int nlines = collcommon_frombinbuf(cc, bb); + if (nlines > 0) + { + t_coll *x; + /* LATER consider making this more robust */ + for (x = cc->c_refs; x; x = x->x_next) + outlet_bang(x->x_filebangout); + cc->c_lastcanvas = cv; + cc->c_filename = fn; + post("coll: finished reading %d lines from text file '%s'", + nlines, fn->s_name); + } + else if (nlines < 0) + loud_error(0, "coll: error in line %d of text file '%s'", + 1 - nlines, fn->s_name); + else + loud_error(0, "coll: error reading text file '%s'", fn->s_name); + if (cc->c_refs) + collcommon_modified(cc, 1); + } + binbuf_free(bb); +} + +static void collcommon_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av) +{ + collcommon_doread((t_collcommon *)z, fn, 0); +} + +static void collcommon_tobinbuf(t_collcommon *cc, t_binbuf *bb) +{ + t_collelem *ep; + t_atom at[3]; + for (ep = cc->c_first; ep; ep = ep->e_next) + { + t_atom *ap = at; + int cnt = 1; + if (ep->e_hasnumkey) + { + SETFLOAT(ap, ep->e_numkey); + ap++; cnt++; + } + if (ep->e_symkey) + { + SETSYMBOL(ap, ep->e_symkey); + ap++; cnt++; + } + SETCOMMA(ap); + binbuf_add(bb, cnt, at); + binbuf_add(bb, ep->e_size, ep->e_data); + binbuf_addsemi(bb); + } +} + +static void collcommon_dowrite(t_collcommon *cc, t_symbol *fn, t_canvas *cv) +{ + t_binbuf *bb; + int ac; + t_atom *av; + char buf[MAXPDSTRING]; + if (!fn && !(fn = cc->c_filename)) /* !fn: 'writeagain' */ + return; + if (cv || (cv = cc->c_lastcanvas)) /* !cv: 'write' w/o arg, 'writeagain' */ + canvas_makefilename(cv, fn->s_name, buf, MAXPDSTRING); + else + { + strncpy(buf, fn->s_name, MAXPDSTRING); + buf[MAXPDSTRING-1] = 0; + } + bb = binbuf_new(); + collcommon_tobinbuf(cc, bb); + if (binbuf_write(bb, buf, "", 0)) + loud_error(0, "coll: error writing text file '%s'", fn->s_name); + else + { + cc->c_lastcanvas = cv; + cc->c_filename = fn; + } + binbuf_free(bb); +} + +static void collcommon_writehook(t_pd *z, t_symbol *fn, int ac, t_atom *av) +{ + collcommon_dowrite((t_collcommon *)z, fn, 0); +} + +static void coll_embedhook(t_pd *z, t_binbuf *bb, t_symbol *bindsym) +{ + t_coll *x = (t_coll *)z; + t_collcommon *cc = x->x_common; + if (cc->c_embedflag) + { + t_collelem *ep; + t_atom at[6]; + binbuf_addv(bb, "ssii;", bindsym, gensym("flags"), 1, 0); + SETSYMBOL(at, bindsym); + for (ep = cc->c_first; ep; ep = ep->e_next) + { + t_atom *ap = at + 1; + int cnt; + if (ep->e_hasnumkey && ep->e_symkey) + { + SETSYMBOL(ap, gensym("nstore")); + ap++; + SETSYMBOL(ap, ep->e_symkey); + ap++; + SETFLOAT(ap, ep->e_numkey); + cnt = 4; + } + else if (ep->e_symkey) + { + SETSYMBOL(ap, gensym("store")); + ap++; + SETSYMBOL(ap, ep->e_symkey); + cnt = 3; + } + else + { + SETFLOAT(ap, ep->e_numkey); + cnt = 2; + } + binbuf_add(bb, cnt, at); + binbuf_add(bb, ep->e_size, ep->e_data); + binbuf_addsemi(bb); + } + } +} + +static void collcommon_editorhook(t_pd *z, t_symbol *s, int ac, t_atom *av) +{ + int nlines = collcommon_fromlist((t_collcommon *)z, ac, av); + if (nlines < 0) + loud_error(0, "coll: editing error in line %d", 1 - nlines); +} + +static t_collcommon *coll_checkcommon(t_coll *x) +{ + if (x->x_name && + x->x_common != (t_collcommon *)pd_findbyclass(x->x_name, + collcommon_class)) + { + bug("coll_checkcommon"); + return (0); + } + return (x->x_common); +} + +static void coll_unbind(t_coll *x) +{ + /* LATER consider calling coll_checkcommon(x) */ + t_collcommon *cc = x->x_common; + t_coll *prev, *next; + if ((prev = cc->c_refs) == x) + { + if (!(cc->c_refs = x->x_next)) + { + hammerfile_free(cc->c_filehandle); + cc->c_loading = 1; /* disable dirty-flag handling, LATER rethink */ + collcommon_clearall(cc); + if (x->x_name) pd_unbind(&cc->c_pd, x->x_name); + pd_free(&cc->c_pd); + } + } + else if (prev) + { + while (next = prev->x_next) + { + if (next == x) + { + prev->x_next = next->x_next; + break; + } + prev = next; + } + } + x->x_common = 0; + x->x_name = 0; + x->x_next = 0; +} + +static void coll_bind(t_coll *x, t_symbol *name) +{ + t_collcommon *cc = 0; + if (name == &s_) + name = 0; + else if (name) + cc = (t_collcommon *)pd_findbyclass(name, collcommon_class); + if (!cc) + { + cc = (t_collcommon *)pd_new(collcommon_class); + cc->c_refs = 0; + cc->c_embedflag = 0; + cc->c_loading = 0; + if (name) + { + pd_bind(&cc->c_pd, name); + /* LATER rethink canvas unpredictability */ + collcommon_doread(cc, name, x->x_canvas); + } + else + { + cc->c_filename = 0; + cc->c_lastcanvas = 0; + } + cc->c_filehandle = hammerfile_new((t_pd *)cc, 0, collcommon_readhook, + collcommon_writehook, + collcommon_editorhook); + } + x->x_common = cc; + x->x_name = name; + x->x_next = cc->c_refs; + cc->c_refs = x; +} + +static int coll_rebind(t_coll *x, t_symbol *name) +{ + t_collcommon *cc; + if (name && name != &s_ && + (cc = (t_collcommon *)pd_findbyclass(name, collcommon_class))) + { + coll_unbind(x); + x->x_common = cc; + x->x_name = name; + x->x_next = cc->c_refs; + cc->c_refs = x; + return (1); + } + else return (0); +} + +static void coll_dooutput(t_coll *x, int ac, t_atom *av) +{ + if (ac > 1) + { + if (av->a_type == A_FLOAT) + outlet_list(((t_object *)x)->ob_outlet, &s_list, ac, av); + else if (av->a_type == A_SYMBOL) + outlet_anything(((t_object *)x)->ob_outlet, + av->a_w.w_symbol, ac-1, av+1); + } + else if (ac) + { + if (av->a_type == A_FLOAT) + outlet_float(((t_object *)x)->ob_outlet, av->a_w.w_float); + else if (av->a_type == A_SYMBOL) + outlet_symbol(((t_object *)x)->ob_outlet, av->a_w.w_symbol); + } +} + +static void coll_keyoutput(t_coll *x, t_collelem *ep) +{ + t_collcommon *cc = x->x_common; + if (!cc->c_entered++) cc->c_selfmodified = 0; + cc->c_relinked = 0; + if (ep->e_hasnumkey) + outlet_float(x->x_keyout, ep->e_numkey); + else if (ep->e_symkey) + outlet_symbol(x->x_keyout, ep->e_symkey); + else + outlet_float(x->x_keyout, 0); + if (cc->c_relinked) cc->c_selfmodified = 1; + cc->c_entered--; +} + +static t_collelem *coll_findkey(t_coll *x, t_atom *key, t_symbol *mess) +{ + t_collcommon *cc = x->x_common; + t_collelem *ep = 0; + if (key->a_type == A_FLOAT) + { + int numkey; + if (loud_checkint((t_pd *)x, key->a_w.w_float, &numkey, mess)) + ep = collcommon_numkey(cc, numkey); + else + mess = 0; + } + else if (key->a_type == A_SYMBOL) + ep = collcommon_symkey(cc, key->a_w.w_symbol); + else if (mess) + { + loud_messarg((t_pd *)x, mess); + mess = 0; + } + if (!ep && mess) + loud_error((t_pd *)x, "no such key"); + return (ep); +} + +static t_collelem *coll_tokey(t_coll *x, t_atom *key, int ac, t_atom *av, + int replace, t_symbol *mess) +{ + t_collcommon *cc = x->x_common; + t_collelem *ep = 0; + if (key->a_type == A_FLOAT) + { + int numkey; + if (loud_checkint((t_pd *)x, key->a_w.w_float, &numkey, mess)) + ep = collcommon_tonumkey(cc, numkey, ac, av, replace); + } + else if (key->a_type == A_SYMBOL) + ep = collcommon_tosymkey(cc, key->a_w.w_symbol, ac, av, replace); + else if (mess) + loud_messarg((t_pd *)x, mess); + return (ep); +} + +static t_collelem *coll_firsttyped(t_coll *x, int ndx, t_atomtype type) +{ + t_collcommon *cc = x->x_common; + t_collelem *ep; + for (ep = cc->c_first; ep; ep = ep->e_next) + if (ep->e_size > ndx && ep->e_data[ndx].a_type == type) + return (ep); + return (0); +} + +/* the methods */ + +static void coll_float(t_coll *x, t_float f) +{ + t_collcommon *cc = x->x_common; + t_collelem *ep; + int numkey; + if (loud_checkint((t_pd *)x, f, &numkey, &s_float) && + (ep = collcommon_numkey(cc, numkey))) + { + coll_keyoutput(x, ep); + if (!cc->c_selfmodified || (ep = collcommon_numkey(cc, numkey))) + coll_dooutput(x, ep->e_size, ep->e_data); + } +} + +static void coll_symbol(t_coll *x, t_symbol *s) +{ + t_collcommon *cc = x->x_common; + t_collelem *ep; + if (ep = collcommon_symkey(cc, s)) + { + coll_keyoutput(x, ep); + if (!cc->c_selfmodified || (ep = collcommon_symkey(cc, s))) + coll_dooutput(x, ep->e_size, ep->e_data); + } +} + +static void coll_list(t_coll *x, t_symbol *s, int ac, t_atom *av) +{ + if (ac >= 2 && av->a_type == A_FLOAT) + coll_tokey(x, av, ac-1, av+1, 1, &s_list); + else + loud_messarg((t_pd *)x, &s_list); +} + +static void coll_anything(t_coll *x, t_symbol *s, int ac, t_atom *av) +{ + coll_symbol(x, s); +} + +static void coll_store(t_coll *x, t_symbol *s, int ac, t_atom *av) +{ + if (ac >= 2) + coll_tokey(x, av, ac-1, av+1, 1, s); + else + loud_messarg((t_pd *)x, s); +} + +static void coll_nstore(t_coll *x, t_symbol *s, int ac, t_atom *av) +{ + if (ac >= 3) + { + t_collcommon *cc = x->x_common; + t_collelem *ep; + int numkey; + if (av->a_type == A_FLOAT && av[1].a_type == A_SYMBOL) + { + if (loud_checkint((t_pd *)x, av->a_w.w_float, &numkey, s)) + { + if (ep = collcommon_symkey(cc, av[1].a_w.w_symbol)) + collcommon_remove(cc, ep); + ep = collcommon_tonumkey(cc, numkey, ac-2, av+2, 1); + ep->e_symkey = av[1].a_w.w_symbol; + } + } + else if (av->a_type == A_SYMBOL && av[1].a_type == A_FLOAT) + { + if (loud_checkint((t_pd *)x, av[1].a_w.w_float, &numkey, s)) + { + if (ep = collcommon_numkey(cc, numkey)) + collcommon_remove(cc, ep); + ep = collcommon_tosymkey(cc, av->a_w.w_symbol, ac-2, av+2, 1); + ep->e_hasnumkey = 1; + ep->e_numkey = numkey; + } + } + else loud_messarg((t_pd *)x, s); + } + else loud_messarg((t_pd *)x, s); +} + +static void coll_insert(t_coll *x, t_symbol *s, int ac, t_atom *av) +{ + if (ac >= 2 && av->a_type == A_FLOAT) + coll_tokey(x, av, ac-1, av+1, 0, s); + else + loud_messarg((t_pd *)x, s); +} + +static void coll_remove(t_coll *x, t_symbol *s, int ac, t_atom *av) +{ + if (ac) + { + t_collelem *ep; + if (ep = coll_findkey(x, av, s)) + collcommon_remove(x->x_common, ep); + } + else loud_messarg((t_pd *)x, s); +} + +static void coll_delete(t_coll *x, t_symbol *s, int ac, t_atom *av) +{ + if (ac) + { + t_collelem *ep; + if (ep = coll_findkey(x, av, s)) + { + if (av->a_type == A_FLOAT) + { + int numkey = ep->e_numkey; + t_collelem *next; + for (next = ep->e_next; next; next = next->e_next) + if (next->e_hasnumkey && next->e_numkey > numkey) + next->e_numkey--; + } + collcommon_remove(x->x_common, ep); + } + } + else loud_messarg((t_pd *)x, s); +} + +static void coll_assoc(t_coll *x, t_symbol *s, t_floatarg f) +{ + int numkey; + if (loud_checkint((t_pd *)x, f, &numkey, gensym("assoc"))) + { + t_collcommon *cc = x->x_common; + t_collelem *ep1, *ep2; + if ((ep1 = collcommon_numkey(cc, numkey)) && + ep1->e_symkey != s) /* LATER rethink */ + { + if (ep2 = collcommon_symkey(cc, s)) + collcommon_remove(cc, ep2); + collcommon_changesymkey(cc, ep1, s); + } + } +} + +static void coll_deassoc(t_coll *x, t_symbol *s, t_floatarg f) +{ + int numkey; + if (loud_checkint((t_pd *)x, f, &numkey, gensym("deassoc"))) + { + t_collcommon *cc = x->x_common; + t_collelem *ep; + if (ep = collcommon_numkey(cc, numkey)) + collcommon_changesymkey(cc, ep, 0); + } +} + +static void coll_subsym(t_coll *x, t_symbol *s1, t_symbol *s2) +{ + t_collelem *ep; + if (s1 != s2 && (ep = collcommon_symkey(x->x_common, s2))) + collcommon_changesymkey(x->x_common, ep, s1); +} + +static void coll_renumber(t_coll *x, t_floatarg f) +{ + int startkey; + if (loud_checkint((t_pd *)x, f, &startkey, gensym("renumber"))) + collcommon_renumber(x->x_common, startkey); +} + +static void coll_merge(t_coll *x, t_symbol *s, int ac, t_atom *av) +{ + if (ac >= 2) + { + t_collcommon *cc = x->x_common; + t_collelem *ep; + if (av->a_type == A_FLOAT) + { + int numkey; + if (loud_checkint((t_pd *)x, av->a_w.w_float, &numkey, s)) + { + if (ep = collcommon_numkey(cc, numkey)) + collcommon_adddata(cc, ep, ac-1, av+1); + else /* LATER consider defining collcommon_toclosest() */ + collcommon_tonumkey(cc, numkey, ac-1, av+1, 1); + } + } + else if (av->a_type == A_SYMBOL) + { + if (ep = collcommon_symkey(cc, av->a_w.w_symbol)) + collcommon_adddata(cc, ep, ac-1, av+1); + else + { + ep = collelem_new(ac-1, av+1, 0, av->a_w.w_symbol); + collcommon_putafter(cc, ep, cc->c_last); + } + } + else loud_messarg((t_pd *)x, s); + } + else loud_messarg((t_pd *)x, s); +} + +static void coll_sub(t_coll *x, t_symbol *s, int ac, t_atom *av) +{ + if (ac) + { + t_collelem *ep; + if (ep = coll_findkey(x, av, s)) + { + t_collcommon *cc = x->x_common; + t_atom *key = av++; + ac--; + while (ac >= 2) + { + if (av->a_type == A_FLOAT) + { + int ndx; + if (loud_checkint((t_pd *)x, av->a_w.w_float, &ndx, 0) + && ndx >= 1 && ndx <= ep->e_size) + ep->e_data[ndx-1] = av[1]; + } + ac -= 2; + av += 2; + } + if (s == gensym("sub")) + { + coll_keyoutput(x, ep); + if (!cc->c_selfmodified || (ep = coll_findkey(x, key, 0))) + coll_dooutput(x, ep->e_size, ep->e_data); + } + } + } + else loud_messarg((t_pd *)x, s); +} + +static void coll_sort(t_coll *x, t_floatarg f1, t_floatarg f2) +{ + int dir, ndx; + if (loud_checkint((t_pd *)x, f1, &dir, gensym("sort")) && + loud_checkint((t_pd *)x, f2, &ndx, gensym("sort"))) + collcommon_sort(x->x_common, (dir < 0 ? 1 : 0), + (ndx < 0 ? -1 : (ndx ? ndx - 1 : 0))); +} + +static void coll_clear(t_coll *x) +{ + collcommon_clearall(x->x_common); +} + +/* According to the refman, the data should be swapped, rather than the keys + -- easy here, but apparently c74 people have chosen to avoid some effort + needed in case of their implementation... */ +static void coll_swap(t_coll *x, t_symbol *s, int ac, t_atom *av) +{ + if (ac == 2) + { + t_collelem *ep1, *ep2; + if ((ep1 = coll_findkey(x, av, s)) && + (ep2 = coll_findkey(x, av + 1, s))) + collcommon_swapkeys(x->x_common, ep1, ep2); + } + else loud_messarg((t_pd *)x, s); +} + +static void coll_next(t_coll *x) +{ + t_collcommon *cc = x->x_common; + if (!cc->c_ahead && !(cc->c_ahead = cc->c_first)) + return; + coll_keyoutput(x, cc->c_ahead); + if (cc->c_selfmodified && !cc->c_ahead) + return; + coll_dooutput(x, cc->c_ahead->e_size, cc->c_ahead->e_data); + /* LATER think why c74 updates the heads prior to sendout + (it seems so clumsy...) */ + if (!cc->c_ahead && !(cc->c_ahead = cc->c_first)) + { + cc->c_back = 0; + return; + } + if (cc->c_ahead->e_next) + { + cc->c_ahead = cc->c_ahead->e_next; + if (!(cc->c_back = cc->c_ahead->e_prev)) /* LATER rethink */ + cc->c_back = cc->c_last; + } + else + { + /* CHECKED wraping */ + cc->c_back = cc->c_ahead; + cc->c_ahead = 0; + } +} + +static void coll_prev(t_coll *x) +{ + t_collcommon *cc = x->x_common; + if (!cc->c_back && !(cc->c_back = cc->c_last)) + return; + coll_keyoutput(x, cc->c_back); + if (cc->c_selfmodified && !cc->c_back) + return; + coll_dooutput(x, cc->c_back->e_size, cc->c_back->e_data); + /* LATER think why c74 updates the heads prior to sendout + (it seems so clumsy...) */ + if (!cc->c_back && !(cc->c_back = cc->c_last)) + { + cc->c_ahead = 0; + return; + } + if (cc->c_back->e_prev) + { + cc->c_back = cc->c_back->e_prev; + if (!(cc->c_ahead = cc->c_back->e_next)) /* LATER rethink */ + cc->c_ahead = cc->c_first; + } + else + { + /* CHECKED wraping */ + cc->c_ahead = cc->c_back; + cc->c_back = 0; + } +} + +static void coll_end(t_coll *x) +{ + t_collcommon *cc = x->x_common; + cc->c_back = cc->c_ahead = cc->c_last; +} + +static void coll_goto(t_coll *x, t_symbol *s, int ac, t_atom *av) +{ + if (ac) + { + t_collelem *ep = coll_findkey(x, av, s); + if (ep) + x->x_common->c_back = x->x_common->c_ahead = ep; + } + else loud_messarg((t_pd *)x, s); +} + +static void coll_nth(t_coll *x, t_symbol *s, int ac, t_atom *av) +{ + if (ac >= 2 && av[1].a_type == A_FLOAT) + { + int ndx; + t_collelem *ep; + if (loud_checkint((t_pd *)x, av[1].a_w.w_float, &ndx, s) && + (ep = coll_findkey(x, av, s)) && + ep->e_size >= ndx) + { + t_atom *ap = ep->e_data + --ndx; + if (ap->a_type == A_FLOAT) + outlet_float(((t_object *)x)->ob_outlet, ap->a_w.w_float); + else if (ap->a_type == A_SYMBOL) + outlet_symbol(((t_object *)x)->ob_outlet, ap->a_w.w_symbol); + } + } + else loud_messarg((t_pd *)x, s); +} + +static void coll_length(t_coll *x) +{ + t_collcommon *cc = x->x_common; + t_collelem *ep = cc->c_first; + int result = 0; + while (ep) result++, ep = ep->e_next; + outlet_float(((t_object *)x)->ob_outlet, result); +} + +static void coll_min(t_coll *x, t_floatarg f) +{ + int ndx; + if (loud_checkint((t_pd *)x, f, &ndx, gensym("min"))) + { + t_collelem *found; + if (ndx <= 0) + ndx = 0; /* LATER consider complaining, CHECKME */ + else ndx--; + if (found = coll_firsttyped(x, ndx, A_FLOAT)) + { + t_float result = found->e_data[ndx].a_w.w_float; + t_collelem *ep; + for (ep = found->e_next; ep; ep = ep->e_next) + { + if (ep->e_size > ndx && + ep->e_data[ndx].a_type == A_FLOAT && + ep->e_data[ndx].a_w.w_float < result) + { + found = ep; + result = ep->e_data[ndx].a_w.w_float; + } + } + coll_keyoutput(x, found); + outlet_float(((t_object *)x)->ob_outlet, result); + } + } +} + +static void coll_max(t_coll *x, t_floatarg f) +{ + int ndx; + if (loud_checkint((t_pd *)x, f, &ndx, gensym("max"))) + { + t_collelem *found; + if (ndx <= 0) + ndx = 0; /* LATER consider complaining, CHECKME */ + else ndx--; + if (found = coll_firsttyped(x, ndx, A_FLOAT)) + { + t_float result = found->e_data[ndx].a_w.w_float; + t_collelem *ep; + for (ep = found->e_next; ep; ep = ep->e_next) + { + if (ep->e_size > ndx && + ep->e_data[ndx].a_type == A_FLOAT && + ep->e_data[ndx].a_w.w_float > result) + { + found = ep; + result = ep->e_data[ndx].a_w.w_float; + } + } + coll_keyoutput(x, found); + outlet_float(((t_object *)x)->ob_outlet, result); + } + } +} + +static void coll_refer(t_coll *x, t_symbol *s) +{ + if (!coll_rebind(x, s)) + { + /* LATER consider complaining */ + } +} + +static void coll_flags(t_coll *x, t_float f1, t_float f2) +{ + int i1; + if (loud_checkint((t_pd *)x, f1, &i1, gensym("flags"))) + { + t_collcommon *cc = x->x_common; + cc->c_embedflag = (i1 != 0); + } +} + +static void coll_read(t_coll *x, t_symbol *s) +{ + t_collcommon *cc = x->x_common; + if (s && s != &s_) + collcommon_doread(cc, s, x->x_canvas); + else + hammerpanel_open(cc->c_filehandle); +} + +static void coll_write(t_coll *x, t_symbol *s) +{ + t_collcommon *cc = x->x_common; + if (s && s != &s_) + collcommon_dowrite(cc, s, x->x_canvas); + else + hammerpanel_save(cc->c_filehandle, 0, 0); /* CHECKME default name */ +} + +static void coll_readagain(t_coll *x) +{ + t_collcommon *cc = x->x_common; + if (cc->c_filename) + collcommon_doread(cc, 0, 0); + else + hammerpanel_open(cc->c_filehandle); +} + +static void coll_writeagain(t_coll *x) +{ + t_collcommon *cc = x->x_common; + if (cc->c_filename) + collcommon_dowrite(cc, 0, 0); + else + hammerpanel_save(cc->c_filehandle, 0, 0); /* CHECKME default name */ +} + +static void coll_filetype(t_coll *x, t_symbol *s) +{ + /* dummy */ +} + +static void coll_dump(t_coll *x) +{ + t_collcommon *cc = x->x_common; + t_collelem *ep; + for (ep = cc->c_first; ep; ep = ep->e_next) + { + coll_keyoutput(x, ep); + if (cc->c_selfmodified) + break; + coll_dooutput(x, ep->e_size, ep->e_data); + } + outlet_bang(x->x_dumpbangout); +} + +static void coll_open(t_coll *x) +{ + t_collcommon *cc = x->x_common; + t_binbuf *bb = binbuf_new(); + int i, natoms, newline; + t_atom *ap; + char buf[MAXPDSTRING]; + /* LATER prepend "coll: " */ + hammereditor_open(cc->c_filehandle, + x->x_name ? x->x_name->s_name : "Untitled"); + collcommon_tobinbuf(cc, bb); + natoms = binbuf_getnatom(bb); + ap = binbuf_getvec(bb); + newline = 1; + while (natoms--) + { + char *ptr = buf; + if (ap->a_type != A_SEMI && ap->a_type != A_COMMA && !newline) + *ptr++ = ' '; + atom_string(ap, ptr, MAXPDSTRING); + if (ap->a_type == A_SEMI) + { + strcat(buf, "\n"); + newline = 1; + } + else newline = 0; + hammereditor_append(cc->c_filehandle, buf); + ap++; + } + binbuf_free(bb); +} + +/* asking and storing the changes -- CHECKME close window, and 'wclose' */ +static void coll_wclose(t_coll *x) +{ + hammereditor_close(x->x_common->c_filehandle, 1); +} + +static void coll_click(t_coll *x, t_floatarg xpos, t_floatarg ypos, + t_floatarg shift, t_floatarg ctrl, t_floatarg alt) +{ + coll_open(x); +} + +#ifdef COLL_DEBUG +static void coll_debug(t_coll *x, t_floatarg f) +{ + t_collcommon *cc = coll_checkcommon(x); + if (cc) + { + t_coll *x1 = cc->c_refs; + t_collelem *ep, *last; + int i = 0; + while (x1) i++, x1 = x1->x_next; + post("refcount %d", i); + for (ep = cc->c_first, last = 0; ep; ep = ep->e_next) last = ep; + if (last != cc->c_last) bug("coll_debug: last element"); + collcommon_post(cc); + } +} +#endif + +static void coll_free(t_coll *x) +{ + hammerfile_free(x->x_filehandle); + coll_unbind(x); +} + +static void *coll_new(t_symbol *s) +{ + t_coll *x = (t_coll *)pd_new(coll_class); + x->x_canvas = canvas_getcurrent(); + outlet_new((t_object *)x, &s_); + x->x_keyout = outlet_new((t_object *)x, &s_); + x->x_filebangout = outlet_new((t_object *)x, &s_bang); + x->x_dumpbangout = outlet_new((t_object *)x, &s_bang); + x->x_filehandle = hammerfile_new((t_pd *)x, coll_embedhook, 0, 0, 0); + coll_bind(x, s); + return (x); +} + +void coll_setup(void) +{ + coll_class = class_new(gensym("coll"), + (t_newmethod)coll_new, + (t_method)coll_free, + sizeof(t_coll), 0, A_DEFSYM, 0); + class_addbang(coll_class, coll_next); + class_addfloat(coll_class, coll_float); + class_addsymbol(coll_class, coll_symbol); + class_addlist(coll_class, coll_list); + class_addanything(coll_class, coll_anything); + class_addmethod(coll_class, (t_method)coll_store, + gensym("store"), A_GIMME, 0); + class_addmethod(coll_class, (t_method)coll_nstore, + gensym("nstore"), A_GIMME, 0); + class_addmethod(coll_class, (t_method)coll_insert, + gensym("insert"), A_GIMME, 0); + class_addmethod(coll_class, (t_method)coll_remove, + gensym("remove"), A_GIMME, 0); + class_addmethod(coll_class, (t_method)coll_delete, + gensym("delete"), A_GIMME, 0); + class_addmethod(coll_class, (t_method)coll_assoc, + gensym("assoc"), A_SYMBOL, A_FLOAT, 0); + class_addmethod(coll_class, (t_method)coll_deassoc, + gensym("deassoc"), A_SYMBOL, A_FLOAT, 0); + class_addmethod(coll_class, (t_method)coll_subsym, + gensym("subsym"), A_SYMBOL, A_SYMBOL, 0); + class_addmethod(coll_class, (t_method)coll_renumber, + gensym("renumber"), A_DEFFLOAT, 0); + class_addmethod(coll_class, (t_method)coll_merge, + gensym("merge"), A_GIMME, 0); + class_addmethod(coll_class, (t_method)coll_sub, + gensym("sub"), A_GIMME, 0); + class_addmethod(coll_class, (t_method)coll_sub, + gensym("nsub"), A_GIMME, 0); + class_addmethod(coll_class, (t_method)coll_clear, + gensym("clear"), 0); + class_addmethod(coll_class, (t_method)coll_sort, + gensym("sort"), A_FLOAT, A_DEFFLOAT, 0); + class_addmethod(coll_class, (t_method)coll_swap, + gensym("swap"), A_GIMME, 0); + class_addmethod(coll_class, (t_method)coll_next, + gensym("next"), 0); + class_addmethod(coll_class, (t_method)coll_prev, + gensym("prev"), 0); + class_addmethod(coll_class, (t_method)coll_end, + gensym("end"), 0); + class_addmethod(coll_class, (t_method)coll_goto, + gensym("goto"), A_GIMME, 0); + class_addmethod(coll_class, (t_method)coll_nth, + gensym("nth"), A_GIMME, 0); + class_addmethod(coll_class, (t_method)coll_length, + gensym("length"), 0); + class_addmethod(coll_class, (t_method)coll_min, + gensym("min"), A_DEFFLOAT, 0); + class_addmethod(coll_class, (t_method)coll_max, + gensym("max"), A_DEFFLOAT, 0); + class_addmethod(coll_class, (t_method)coll_refer, + gensym("refer"), A_SYMBOL, 0); + class_addmethod(coll_class, (t_method)coll_flags, + gensym("flags"), A_FLOAT, A_FLOAT, 0); + class_addmethod(coll_class, (t_method)coll_read, + gensym("read"), A_DEFSYM, 0); + class_addmethod(coll_class, (t_method)coll_write, + gensym("write"), A_DEFSYM, 0); + class_addmethod(coll_class, (t_method)coll_readagain, + gensym("readagain"), 0); + class_addmethod(coll_class, (t_method)coll_writeagain, + gensym("writeagain"), 0); + class_addmethod(coll_class, (t_method)coll_filetype, + gensym("filetype"), A_SYMBOL, 0); + class_addmethod(coll_class, (t_method)coll_dump, + gensym("dump"), 0); + class_addmethod(coll_class, (t_method)coll_open, + gensym("open"), 0); + class_addmethod(coll_class, (t_method)coll_wclose, + gensym("wclose"), 0); + class_addmethod(coll_class, (t_method)coll_click, + gensym("click"), + A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); +#ifdef COLL_DEBUG + class_addmethod(coll_class, (t_method)coll_debug, + gensym("debug"), A_DEFFLOAT, 0); +#endif + hammerfile_setup(coll_class, 1); + collcommon_class = class_new(gensym("coll"), 0, 0, + sizeof(t_collcommon), CLASS_PD, 0); + /* this call is a nop (collcommon does not embed, and the hammerfile + class itself has been already set up above), but it is better to + have it around, just in case... */ + hammerfile_setup(collcommon_class, 0); +} diff --git a/cyclone/hammer/comment.c b/cyclone/hammer/comment.c new file mode 100644 index 0000000..e5cd5ab --- /dev/null +++ b/cyclone/hammer/comment.c @@ -0,0 +1,835 @@ +/* Copyright (c) 2002-2003 krzYszcz and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* FIXME creation lag (X-specific) */ +/* LATER think about pushing text to the text editor (ctrl-t) + -- not easy, because we are not 'textedfor' */ + +#include +#include +#include +#include +#include "m_pd.h" +#include "g_canvas.h" +#include "common/loud.h" + +/* our proxy of the text_class (not in the API), LATER do not cheat */ +static t_class *makeshift_class; + +//#define COMMENT_DEBUG + +#define COMMENT_LMARGIN 1 +#define COMMENT_RMARGIN 1 +#define COMMENT_TMARGIN 2 +#define COMMENT_BMARGIN 2 +#define COMMENT_MINWIDTH 8 +#define COMMENT_HANDLEWIDTH 8 +#define COMMENT_OUTBUFSIZE 1000 + +typedef struct _comment +{ + t_object x_ob; + t_glist *x_glist; + t_canvas *x_canvas; /* also an 'isvised' flag */ + t_symbol *x_bindsym; + char x_tag[32]; + char x_texttag[32]; + char x_outlinetag[32]; + t_clock *x_transclock; + t_binbuf *x_binbuf; + char *x_textbuf; + int x_textbufsize; + int x_pixwidth; + int x_bbset; + int x_bbpending; + int x_x1; + int x_y1; + int x_x2; + int x_y2; + int x_newx2; + int x_dragon; + int x_fontsize; /* requested size */ + t_symbol *x_fontfamily; /* requested family */ + int x_fontprops; /* LATER pack weight and slant */ + t_symbol *x_encoding; /* requested encoding */ + unsigned char x_red; + unsigned char x_green; + unsigned char x_blue; + char x_color[8]; + int x_selstart; + int x_selend; + int x_active; + int x_ready; +} t_comment; + +static t_class *comment_class; +static t_class *commentsink_class; + +static t_pd *commentsink = 0; + +static void comment_draw(t_comment *x) +{ + char buf[COMMENT_OUTBUFSIZE], *outbuf, *outp; + int cvid = (int)x->x_canvas; + int reqsize = x->x_textbufsize + 350; /* FIXME estimation */ + if (reqsize > COMMENT_OUTBUFSIZE) + { +#ifdef COMMENT_DEBUG + post("allocating %d outbuf bytes", reqsize); +#endif + if (!(outbuf = getbytes(reqsize))) + return; + } + else outbuf = buf; + outp = outbuf; + if (x->x_encoding) + sprintf(outp, "set tt [comment_entext %s {%.*s}]\n", + x->x_encoding->s_name, x->x_textbufsize, x->x_textbuf); + else + sprintf(outp, "set tt {%.*s}\n", x->x_textbufsize, x->x_textbuf); + outp += strlen(outp); + sprintf(outp, ".x%x.c create text %f %f -text $tt \ + -tags {%s %s} -font {%s %d} -fill %s", cvid, + (float)(text_xpix((t_text *)x, x->x_glist) + COMMENT_LMARGIN), + (float)(text_ypix((t_text *)x, x->x_glist) + COMMENT_TMARGIN), + x->x_texttag, x->x_tag, x->x_fontfamily->s_name, x->x_fontsize, + (glist_isselected(x->x_glist, &x->x_glist->gl_gobj) ? + "blue" : x->x_color)); + outp += strlen(outp); + if (x->x_pixwidth) + sprintf(outp, " -width %d -anchor nw\n", x->x_pixwidth); + else + strcpy(outp, " -anchor nw\n"); + outp += strlen(outp); + sprintf(outp, "comment_bbox %s .x%x.c %s\n", + x->x_bindsym->s_name, cvid, x->x_texttag); + outp += strlen(outp); + sprintf(outp, ".x%x.c bind %s