JMSL Tutorial: JScore
Implementing your own Unary Copy Buffer Transform, part 1

You can design your own UnaryCopyBufferTransform by extending UnaryCopyBufferTransform and overriding public void operate(CopyBuffer copyBuffer). The operate() method receives the CopyBuffer, which contains the Notes upon which to operate. CopyBuffer is a java.util.Vector, so Notes in the buffer can be examined, added, deleted, and mutated like any Object in a Vector.

Let us examine the source code for the Retrograde Transform, which is below. Notice the constructor assigns a unique name to the transform. This name will show up in the ScoreFrame's menu when it is added later.
package com.softsynth.jmsl.score;

public class RetrogradeTransform extends UnaryCopyBufferTransform {
	public RetrogradeTransform() {
		name = "Retrograde";

/** Implement this method to do whatever you want to CopyBuffer arg.  */
 public void operate(CopyBuffer copyBuffer) {
	int start =0;
	int end = copyBuffer.size()-1;
	while (start < end) {
		Object temp = copyBuffer.elementAt(start);
		copyBuffer.setElementAt(copyBuffer.elementAt(end), start);
		copyBuffer.setElementAt(temp, end);
Previous Tutorial Index Tutorial Contents Next

  (C) 2000 Nick Didkovsky and Phil Burk, All Rights Reserved
  JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom.