home *** CD-ROM | disk | FTP | other *** search
/ Logiciels PC 21 / LogicielsPC_21.iso / Musique / Jambient / jambient.CAB / ExampleScript.jms < prev    next >
Text File  |  2000-09-06  |  14KB  |  436 lines

  1. Option Explicit
  2.  
  3. 'A bunch of constants that help make the code read better
  4.  
  5. 'For identifying loops
  6. Const A = 1
  7. Const B = 2
  8. Const c = 3
  9. Const D = 4
  10. Const E = 5
  11. Const f = 6
  12. Const g = 7
  13. Const H = 8
  14. Const i = 9
  15. Const j = 10
  16. Const k = 11
  17. Const l = 12
  18. Const M = 13
  19. Const N = 14
  20. Const o = 15
  21. Const p = 16
  22. Const Gang = 17
  23. Const Listener = 17
  24.  
  25. 'For playstates
  26. Const StopIt = 0
  27. Const PlayIt = 1
  28. Const PauseIt = 2
  29. Const UnpauseIt = 3
  30.  
  31. 'For playmodes
  32. Const OneShot = 1
  33. Const LoopLoop = 2
  34. Const Track = 3
  35. Const Drum = 4
  36.  
  37. 'For types of patterns
  38. Const VolPattern = 1
  39. Const PithcPattern = 2
  40. Const PanPattern = 3
  41.  
  42. 'For fading
  43. Const FadeOff = 0
  44. Const FadeUp = 1
  45. Const FadeSwitch = 2
  46. Const FadeDown = 3
  47.  
  48. 'For identifying types of buttons
  49. Const SliderType = 0
  50. Const ButtonType = 1
  51. Const CheckType = 2
  52. Const DropDownType = 3
  53.  
  54.  
  55. Const pi=3.1415926535897932
  56.  
  57. 'This variable controls what happens
  58. 'in OnPositionScroll
  59. Dim PositionBehaviour
  60.  
  61. 'For moving the mix pad ball in an orbit
  62. Dim DegreeStep
  63. Dim RandomRadius
  64. Dim Degree
  65.  
  66. 'For knudging loops
  67. Dim KnudgeAmount
  68.  
  69. Dim ToScramble(16)  'keeps track of which loops to scramble
  70. Dim ScrambleAmount
  71.  
  72.  
  73. '========================
  74. 'PitchIt and InitPitchIt let the user
  75. 'bump the pitch of gang controlled loops up and down
  76.  
  77. Sub PitchIt(ListIndex, ItemText)
  78. 'this is fired whenever the user selects an option from
  79. 'the drop down
  80.      Dim Lp
  81.     Select Case ItemText
  82.     Case "Half Pitch (Gang)"
  83.       For Lp = A To p
  84.           If jam.IsGanged(Lp) Then
  85.                   jam.Pitch(Lp) = jam.Pitch(Lp) / 2
  86.           End If
  87.       Next
  88.     Case "Double Pitch (Gang)"
  89.       For Lp = A To p
  90.           If jam.IsGanged(Lp) Then
  91.                   jam.Pitch(Lp) = jam.Pitch(Lp) * 2
  92.           End If
  93.       Next
  94.     end Select
  95.     PitchDropDown.ListIndex = 0
  96. End Sub
  97.  
  98. Sub InitPitchIt
  99.     if jam.AttachControl("PitchIt",DropDownType, "PitchDropDown") then
  100.        'if we were successful in attaching a drop down to the ScrollingType Procedure
  101.        'then the PosDropdown object is created
  102.        'manipulate it
  103.        with PitchDropDown
  104.          .Clear 'ensure clean slate if a reload is called
  105.          .AddItem "<Chng Gang Pitch>"
  106.          .AddItem "Half Pitch (Gang)"
  107.          .AddItem "Double Pitch (Gang)"
  108.          .ToolTipText = "Pitch up or down; click first option to cancel."
  109.          .ListIndex = 0 'set to first option
  110.        end with
  111.     end if
  112.  
  113. end sub
  114.  
  115. '==========================
  116. 'InitScrolling, PositionType, OnPositionScroll and the variable
  117. 'Position behaviour make up a code set that responds to movement
  118. 'on the 3d map
  119.  
  120. Sub PositionType(ListIndex, ItemText)
  121. 'Init scrolling attached a drop down list box to the control
  122. 'when the user clicks on it, the listindex of the selection and its text
  123. 'are passed to this procedure
  124.      PositionBehaviour = ListIndex
  125.      jam.ReadOut LIstIndex & "  " & ItemText
  126. End Sub
  127.  
  128. Sub OnPositionScroll(LoopIndex, X, Y, DX, DY)
  129. 'Sub OnPositionChange(LoopIndex, X, Y)
  130. 'this is an example of a scrolling event that is called
  131. 'when the user moves loops in the 3d map
  132. 'The behaviour depends on PositionBehaviour which is controlled
  133. 'through the drop down attached to sub PositionType
  134. 'In the mirror behaviour,
  135. 'the first 8 looptracks control the position of the one's 8 looptracks after,
  136.         Dim i
  137.         Dim Band
  138.         Dim NX
  139.         Dim NY
  140.         'jam.Readout X & ": " '& DX
  141.         Select Case PositionBehaviour 'this is set using SldMirrorType, when sliders are working
  142.         Case 0 'mirroring around both axes
  143.                 If LoopIndex <= 8 Then
  144.                         jam.SetXY LoopIndex + 8, X * -1, Y * -1
  145.                 End If
  146.         Case 1 'mirroring around X axis only
  147.                 If LoopIndex <= 8 Then
  148.                         jam.SetXY LoopIndex + 8, X * -1, Y
  149.                 End If
  150.         Case 2 'mirroring around Y axis only
  151.                 If LoopIndex <= 8 Then
  152.                         jam.SetXY LoopIndex + 8, X, Y * -1
  153.                 End If
  154.         Case 3
  155.           if LoopIndex<>Listener then
  156.             Band = jam.BandOf(LoopIndex)
  157.             if LoopIndex = jam.BandFirst(Band) then
  158.                'this is the first loop in the band
  159.                For i = jam.BandFirst(Band) To jam.BandLast(Band)
  160.                       If i <> LoopIndex Then
  161.                               jam.GetXY i, NX, NY
  162.                               jam.SetXY i, NX +DX, NY+DY
  163.                       End If
  164.                Next
  165.             end if
  166.           end if
  167.         Case 4
  168.           if LoopIndex=Listener then
  169.              for i = jam.BandFirst(0) to jam.BandLast(0)
  170.                  jam.GetXY i, NX, NY
  171.                  jam.SetXY i, NX +DX, NY+DY
  172.              next
  173.           end if
  174.         End Select
  175. End Sub
  176.  
  177. Sub InitScrolling
  178.     Dim MyControl
  179.     if jam.AttachControl("PositionType",DropDownType, "PosDropDown") then
  180.        'if we were successful in attaching a drop down to the ScrollingType Procedure
  181.        'then the PosDropdown object is created
  182.        'manipulate it
  183.        with PosDropDown
  184.          .Clear 'ensure clean slate if a reload is called
  185.          .AddItem "XY Mirror"
  186.          .AddItem "X Mirror"
  187.          .AddItem "Y Mirror"
  188.          .AddItem "Flying Wedge"
  189.          .AddItem "Red band follow listener"
  190.          .AddItem "None"
  191.          .ToolTipText = "Choose behaviour for scrolling routines."
  192.          .ListIndex = 0 'set to xy mirror
  193.        end with
  194.     end if
  195. End Sub
  196.  
  197.  
  198.  
  199. '================================
  200. 'the following subs make up another code set that
  201. 'makes the mix pad cursor move in circles
  202.  
  203. Sub ToggleClock (Checked)
  204.     'respond to check box toggling by toggling clock
  205.     jam.Clock = checked
  206. end sub
  207.  
  208. Sub ClockInterval (Value, Scrolling)
  209.     jam.Readout "Clock interval: " & Value & "ms"
  210.     if not Scrolling then
  211.        jam.ClockInterval = Value
  212.     end if
  213. end sub
  214.  
  215. Sub DegreeTurn (Value,Scrolling)
  216.     jam.Readout "Degree Step per Clock tick : " & Value
  217.     if Scrolling then
  218.        'the user is still scrolling, with the mouse button down
  219.     else
  220.        'the user has let go of the mouse button
  221.        DegreeStep = Value
  222.     end if
  223. end sub
  224.  
  225. Sub RandomRadiusSlider (Value,Scrolling)
  226.     jam.Readout "Random Radius : " & Value
  227.     if Scrolling then
  228.        'the user has let go of the mouse button
  229.        RandomRadius = Value
  230.     end if
  231. end sub
  232.  
  233. Sub ScrambleSlider (Value,Scrolling)
  234.     Dim Lp
  235.     jam.ReadOut "Scramble by " & Value & "%"
  236.     if not Scrolling then
  237.       for Lp = a to p
  238.           ToScramble(lp)=jam.IsGanged(Lp)
  239.       next
  240.       ScrambleAmount = Value
  241.     end if
  242. end sub
  243.  
  244. Sub OnClock(DeltaMilliSeconds, SessionSeconds, SessionMilliSeconds)
  245. 'when the clock fires, this event handler is called
  246. 'DeltaMilliSeconds is the number of milliseconds since the last clock fire
  247. 'SessionSeconds is the number of seconds since the beginning of the session
  248. 'SessionMilliSeconds is the number of milliseconds since the beginning of the session
  249.      Dim r
  250.      Dim Lp
  251.      if DegreeStep<>0 then
  252.        'function for circle given angle; * pi/180 converts degrees to radians
  253.        r = RandomRadius*rnd()
  254.        jam.Readout "Clock " & Degree
  255.        jam.PadPolar Degree, 0.5+ RandomRadius*rnd() ',0.2,0.2' XY cos(Degree* pi/180 )*(0.5+r), sin(Degree* pi/180 )*(0.5+r)
  256.        Degree = Degree+DegreeStep
  257.        if Degree>360 then
  258.            Degree = Degree-360
  259.        end if
  260.      end if
  261.      if abs(ScrambleAmount)>3 then
  262.         For Lp = A To p
  263.             If ToScramble(Lp) Then
  264.                     jam.Pos(Lp) = jam.Pos(Lp) - (rnd()*ScrambleAmount)
  265.             End If
  266.         Next
  267.      end if
  268. End Sub
  269.  
  270. Sub ScrambleWires()
  271.     Dim Lp
  272.     for Lp = A to P
  273.         jam.Wire(Lp)=int(4*rnd+1) ' assign a random channel
  274.     next
  275. End sub
  276.  
  277.  
  278. Sub InitClock
  279.     if jam.AttachControl("ToggleClock",CheckType, "ClockCheck") then
  280.        'if a check box is successfully attached, then
  281.        'it's in the object check
  282.        with ClockCheck
  283.             .caption = "Clock On"
  284.             .tooltiptext ="Toggle clock on and off to trigger events in time"
  285.  
  286.        end with
  287.     end if
  288.     if jam.AttachControl("ClockInterval",SliderType, "ClockSlider") then
  289.        'if a check box is successfully attached, then
  290.        'it's in the object check
  291.        with ClockSlider
  292.              .tooltiptext ="Set clock interval"
  293.             'have to call this to set caption because of bad positioning in the slider control
  294.             jam.SetSliderCaption ClockSlider, "Clk Interval"
  295.             .ScaleMin =20
  296.             .ScaleMax = 200
  297.             .PointerValue 20
  298.             jam.ClockInterval = .PointerValue
  299.        end with
  300.     end if
  301.     if jam.AttachControl("ScrambleSlider",SliderType, "ScramSlider") then
  302.        'if a check box is successfully attached, then
  303.        'it's in the object check
  304.        with ScramSlider
  305.              .tooltiptext ="If <> 0 then ganged loops will be repositioned by and rand % based on this value, on each clock ticks"
  306.             'have to call this to set caption because of bad positioning in the slider control
  307.             jam.SetSliderCaption ScramSlider, "Scramble Amount"
  308.             .ScaleMin =-90
  309.             .ScaleMax = 90
  310.             .PointerValue 0
  311.             ScrambleAmount = .PointerValue
  312.        end with
  313.     end if
  314.     if jam.AttachControl("DegreeTurn",SliderType, "DegreeSlider") then
  315.        'if a check box is successfully attached, then
  316.        'it's in the object check
  317.        with DegreeSlider
  318.             'have to call this to set caption because of bad positioning in the slider control
  319.             jam.SetSliderCaption DegreeSlider, "Degree Step"
  320.             .ScaleMin =0
  321.             .ScaleMax = 10
  322.             .PointerValue 0
  323.             DegreeStep = .PointerValue
  324.             .ToolTipText = "Set degree step; 0 to turn off"
  325.        end with
  326.     end if
  327.     if jam.AttachControl("RandomRadiusSlider",SliderType, "RadiusSlider") then
  328.        'if a check box is successfully attached, then
  329.        'it's in the object check
  330.        with RadiusSlider
  331.              .tooltiptext ="Set random radius factor for pad cursor movement"
  332.             'have to call this to set caption because of bad positioning in the slider control
  333.             jam.SetSliderCaption RadiusSlider, "Rnd Radius"
  334.             .ScaleMin =0
  335.             .ScaleMax = 0.5
  336.             .PointerValue 0
  337.             RandomRadius = .PointerValue
  338.             .ToolTipText = "Set rand radius"
  339.        end with
  340.     end if
  341.     if jam.AttachControl("ScrambleWires",ButtonType, "Scramble") then
  342.        'if the Scramble button is successfully attached,
  343.        with Scramble
  344.             .caption = "Scramble Wires"
  345.             .tooltiptext ="Click to generate a random wire assignment"
  346.        end with
  347.     end if
  348.     'Initialize variables
  349.     Degree=0
  350.     jam.ClockInterval = 40
  351. end sub
  352.  
  353.  
  354. '================================
  355. 'this code set is for knudging ganged loops back and forth
  356.  
  357. Sub Knudge(Value, Scrolling)
  358.     Dim Lp
  359.     jam.ReadOut "Knudge Amount: " & Value & "% of sample"
  360.     if not Scrolling then
  361.       For Lp = A To p
  362.           If jam.IsGanged(Lp) Then
  363.                   jam.Pos(Lp) = jam.Pos(Lp) - Value
  364.           End If
  365.       Next
  366.     end if
  367. end sub
  368.  
  369. Sub InitKnudge()
  370. 'set up controls for the knudge procedure
  371.     if jam.AttachControl("Knudge",SliderType, "KnudgeSlider") then
  372.        'if the knudgeslider is successfully attached
  373.        with KnudgeSlider
  374.              .tooltiptext ="Click pointer to knudge, slide pointer to adjust knudge amount."
  375.             'have to call this to set caption because of bad positioning in the slider control
  376.             jam.SetSliderCaption KnudgeSlider, "Knudge"
  377.             .ScaleMin =-90
  378.             .ScaleMax = 90
  379.             .PointerValue 50
  380.              .ToolTipText = "Knudge loop forward or backward"
  381.        end with
  382.     end if
  383. End Sub
  384.  
  385. '============================
  386. 'various event handlers
  387. Sub OnPanChange(LoopIndex, Pan)
  388. 'an example of an event handler; CHANGE handlers are called when
  389. 'the knob is finished turning
  390. 'this one makes loop B be twice the pitch of A
  391.         If LoopIndex = A Then
  392.                 jam.Pan(B) = Pan*-1
  393.         End If
  394. End Sub
  395.  
  396. Sub OnPanScroll(LoopIndex, Pan, DPan)
  397. 'an example of an event handler; CHANGE handlers are called when
  398. 'the knob is finished turning
  399. 'this one makes loop B be twice the pitch of A
  400.         If LoopIndex = o Then
  401.                 jam.Pan(P) = jam.Pan(P) +DPan
  402.         End If
  403. End Sub
  404.  
  405.  
  406. Sub OnVolChange(LoopIndex, Vol)
  407. 'an example of an event handler; CHANGE handlers are called when
  408. 'the knob is finished turning
  409. 'this one makes loop B be twice the pitch of A
  410.         If LoopIndex = A Then
  411.                 jam.Vol(B) = Vol/2
  412.         End If
  413. End Sub
  414.  
  415. Sub OnVolScroll(LoopIndex, Vol, DVol)
  416. 'an example of an event handler; CHANGE handlers are called when
  417. 'the knob is finished turning
  418. 'this one makes loop B be twice the pitch of A
  419.         If LoopIndex = o Then
  420.                 jam.Vol(P) = jam.Vol(P) +DVol
  421.         End If
  422. End Sub
  423.  
  424.  
  425. Sub OnPitchScroll(LoopIndex, Pitch, DPitch)
  426. 'an example of an event handler; CHANGE handlers are called when
  427. 'the knob is finished turning
  428. 'this one makes loop B be twice the pitch of A
  429.         If LoopIndex = o Then
  430.                 jam.Pitch(P) = jam.Pitch(P) +DPitch
  431.         End If
  432. End Sub
  433.  
  434.  
  435.  
  436.