Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

v97i004: CCCC - Bars & Pipes event tool, Part 01/01

1 view
Skip to first unread message

Richard Hagen

unread,
Oct 27, 1997, 3:00:00 AM10/27/97
to

Submitted-by: Richard Hagen <R.H...@mailbox.uq.edu.au>
Posting-number: Volume 97, Issue 04
Archive-name: music/CCCC-1.3/part01
URL: http://www.it.uq.edu.au/~richard/music/bars-and-pipes/index.html#programs

[ Executable (cccc.ptool) included. ...zim ]

CCCC generates events, but can be used anywhere in pipelines.
It can't be used as a padtool.

#!/bin/sh
# This is music/CCCC-1.3, a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 10/27/1997 18:24 UTC by z...@ibx.com
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 24965 -rw------- cccc.c
# 5552 -rw------- cccc.ptool
# 3885 -rw------- cccc.readme
# 1299 -rw------- dmakefile
# 2288 -rw------- myheader.h
#
if test -r _shar_seq_.tmp; then
echo 'Must unpack archives in sequence!'
echo Please unpack part `cat _shar_seq_.tmp` next
exit 1
fi
# ============= cccc.c ==============
if test -f 'cccc.c' -a X"$1" != X"-c"; then
echo 'x - skipping cccc.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting cccc.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'cccc.c' &&
/*
X cccc: A Bars and Pipes tool for creating cylcically changing control changes.
X
X Copyright (C) 1997 Richard Hagen
X This code is released into the Public Domain, and may be freely
X distributed in its original form.
X
X It is supplied ``as is'', and comes with no warranty.
X This program code was released because it might be useful as a
X starting point for other programmers. However, if any damage arises
X from its use, the original author will not be held liable.
X
X You are free to use and modify this code to your heart's content,
X provided you acknowledge me as the original author in any code
X that you might distribute which is based largely on this code.
X
X I acknowledge that the design of this accessory is influenced
X strongly by the example code supplied with the Rules for Tools
X package. However, I have made substantial contributions of my
X own.
X
X Richard Hagen
X ric...@it.uq.edu.au
X 8 September 1997
X
X History:
X Version 1.4 (22 September 1997)
X Made sure that two consecutive messages with identical values
X weren't produced.
X
X Version 1.3 (22 September 1997)
X Added TRIANGLE2 waveform. Made it a normal tool.
X
X Version 1.2 (13 September 1997)
X Redrew icon. Added the tool type NOTPAD.
X
X Version 1.1 (9 September 1997)
X Made sure the period couldn't be zero clocks.
X
X Version 1.0 (8 September 1997)
X Initial release.
*/
X
#include <libraries/dos.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <exec/memory.h>
#include <string.h>
#include <intuition/intuition.h>
#include <intuition/sghooks.h>
X
#include "bars.h"
#include "myheader.h"
X
#define CCCC_NAME "CCCC 1.3"
X
#define ID_CCCC MAKE_IDS("CCCC")
X
#define CCCC_TYPE (TOOL_NORMAL | TOOL_NOTPAD)
X
__chip static UWORD cccc[] = {
X /*------ plane # 0: --------*/
X 0x0, 0x0,
X 0x3fff, 0xfc00,
X 0x2000, 0x0400,
X 0x2003, 0x0400,
X 0x2004, 0x3400,
X 0x2004, 0x4400,
X 0x2004, 0x4400,
X 0x2003, 0x4400,
X 0x2000, 0x3400,
X 0x2000, 0x0400,
X 0x3fff, 0xfc00,
X 0x0, 0x0,
X
X /*------ plane # 1: --------*/
X 0x0, 0x0,
X 0x0, 0x0400,
X 0x1fff, 0xfc00,
X 0x19fc, 0xfc00,
X 0xd7fb, 0xfb00,
X 0xd7fb, 0xfb00,
X 0xd7fb, 0xfb00,
X 0xd9fc, 0xfb00,
X 0x1fff, 0xfc00,
X 0x1fff, 0xfc00,
X 0x1fff, 0xfc00,
X 0x0, 0x0,
X
X /*------ plane # 2: --------*/
X 0x0, 0x0,
X 0x0, 0x0,
X 0x0, 0x0,
X 0x0603, 0x0,
X 0x0834, 0x3000,
X 0x0844, 0x4000,
X 0x0844, 0x4000,
X 0x0643, 0x4000,
X 0x0030, 0x3000,
X 0x0, 0x0,
X 0x0, 0x0,
X 0x0, 0x0,
};
X
static struct Image cccc_image = {
X 0,0,
X 24 , 12 , 3 ,
X &cccc[0],
X 0x1f,0x00,
X NULL
};
X
/* The waveforms that might be selected. */
enum Wave {
X TRIANGLE = 0L,
X SAW = 1L,
X SQUARE = 2L,
X RANDOM = 3L,
X TRIANGLE2 = 4L
};
X
/* Possibilities for initial direction of waves. */
enum Direction { UP = 0L, DOWN = 1L };
X
struct CCCCTool {
X struct Tool tool;
X char controller; /* Controller number to be varied. */
X long start; /* When to start varying. */
X long finish; /* When to stop varying. */
X long period; /* Period of variation. */
X enum Wave wave; /* Waveform to be used. */
X enum Direction direction; /* Initial direction of waveform. */
X long granularity; /* How often to send updates of
X controller value. */
X
X BYTE last; /* Value of last messge. */
};
X
extern struct Functions *functions;
X
/* Some initial values. */
#define INIT_CC 10L
#define INIT_PERIOD (CLOCKSPERMEASURE)
#define INIT_WAVE (TRIANGLE)
#define INIT_DIRECTION (UP)
#define INIT_GRANULARITY 2L
X
static void
X cccc_tool_init(struct CCCCTool *tool)
{
X tool->tool.touched = TOUCH_INIT;
X
X tool->controller = INIT_CC;
X tool->start = 0L;
X tool->finish = functions->stoptime;
X tool->period = INIT_PERIOD;
X tool->wave = INIT_WAVE;
X tool->direction = INIT_DIRECTION;
X tool->granularity = INIT_GRANULARITY;
X
X tool->last = -1;
}
X
static struct ToolMaster master;
X
/* Compute the value of the controller. */
static UBYTE
X wave_value(const enum Wave wave, /* Wave form being output. */
X const enum Direction direction, /* Initial direction. */
X const long loc, /* Where in the cycle we are. */
X const long period) /* How long the cycle is. */
{
X UBYTE val = 0;
X
X switch (wave)
X {
X case TRIANGLE:
X {
X const long tmp = (loc << 8) / period;
X const long quarter = period >> 2;
X
X if (loc < quarter)
X {
X val = 64 + tmp;
X }
X else if (loc < 3 * quarter)
X {
X val = 192 - tmp;
X }
X else
X {
X val = tmp - 192;
X }
X break;
X }
X case SAW:
X val = (loc << 7) / period;
X break;
X case SQUARE:
X if (loc < (period >> 1))
X {
X val = CC_VALUE_MAX;
X }
X else
X {
X val = 0;
X }
X break;
X case RANDOM:
X val = (*functions->random)(CC_VALUE_NUM);
X break;
X case TRIANGLE2:
X if (loc < (period >> 1))
X {
X val = (loc << 8) / period;
X }
X else
X {
X val = CC_VALUE_MAX - (((loc << 1) - period) << 7) / period;
X }
X break;
X }
X return direction == UP ? val : CC_VALUE_MAX - val;
}
X
/* Display the value of the controller. */
static void
display_value(struct Window *window, /* Window to display in. */
X UBYTE value) /* The value to display. */
{
X char string[10];
X
X struct RastPort *rp = window->RPort;
X sprintf(string, "%3ld", value);
X Move(rp, 229, 21);
X SetAPen(rp, 1);
X SetBPen(rp, 0);
X SetDrMd(rp, JAM2);
X Text(rp, string, 3);
}
X
/* Generate and queue a batch of controller events. */
static void
X queue_cccc_events(struct CCCCTool *tool, /* Where the parameters come from. */
X long start, /* Start time of batch. */
X long end) /* End time of batch. */
{
X /* Do we need to do any work? */
X if (end < tool->start || tool->finish < start)
X {
X return;
X }
X
X /* Make sure the time range for generated events
X respects the settings in the tool. */
X if (start < tool->start)
X {
X start = tool->start;
X }
X if (tool->finish < end)
X {
X end = tool->finish;
X }
X
X /* For each quantum, create and queue the controller event. */
X for (long time = start;
X time < end;
X time += NOTE_LENGTH(tool->granularity))
X {
X const long position = (time - tool->start) % tool->period;
X const UBYTE value = wave_value(tool->wave, tool->direction,
X position, tool->period);
X
X if (value != tool->last)
X {
X struct Event *event = (struct Event *)(*functions->allocevent)();
X if (event)
X {
X event->next = NULL;
X event->time = time;
X event->type = EVENT_VOICE;
X event->status = MIDI_CCHANGE;
X event->byte1 = tool->controller;
X event->byte2 = value;
X event->tool = tool->tool.next;
X (*functions->qevent)(event);
X
X /* If the tool has an open window, display the value. */
X if (tool->tool.window)
X {
X display_value(tool->tool.window, value);
X }
X }
X tool->last = value;
X }
X }
}
X
/* Called whenever something happens in the transport. */
__geta4 /* Callback. */
void transportcode(long command, /* Transport command. */
X long start, /* Start time for command. */
X long end) /* End time for command. */
{
X switch (command)
X {
X case TC_START:
X case TC_PLAY:
X case TC_TICK:
X /* Find all the CCCCTools and get them to do their thing. */
X for (struct Track *track = functions->tracklist;
X track;
X track = track->next)
X {
X for (struct Tool *tool = track->toollist;
X tool;
X tool = tool->next)
X {
X if (tool && (tool->toolid == ID_CCCC))
X {
X if (!tool->touched)
X {
X cccc_tool_init((struct CCCCTool *)tool);
X }
X queue_cccc_events((struct CCCCTool *)tool, start, end);
X }
X }
X }
X break;
X default:
X break;
X }
}
X
/* Gadget identifiers. */
#define CCCC_CC_GADGET 1
#define CCCC_CCDOWN_GADGET 2
#define CCCC_CCUP_GADGET 3
#define CCCC_START_GADGET 4
#define CCCC_FINISH_GADGET 5
#define CCCC_PERIOD_GADGET 6
#define CCCC_WAVE_GADGET 7
#define CCCC_DIRECTION_GADGET 8
#define CCCC_GRANULARITY_GADGET 9
X
/* Strings naming the various entities declared in enumerated types above. */
static const char *wave_names[] = {
X "Triangle",
X " Saw ",
X " Square ",
X " Random ",
X " Tri2 "
};
X
static const char *direction_names[] = { " Up ", "Down" };
X
static const char *note_names[] = {" 1 ","1/2 ","1/4 ","1/8 ","1/16","1/32", "1/64"};
X
/* Granularity gadget. */
SHORT CCCCBorderVectors1[] = {
X 0,0,
X 81,0,
X 81,12,
X 0,12,
X 0,0
};
X
struct Border CCCCBorder1 = {
X -1,-1,
X 3,0,JAM1,
X 5,
X CCCCBorderVectors1,
X NULL
};
X
struct IntuiText CCCCIText1 = {
X 4,0,JAM1,
X 25,1,
X NULL,
X NULL, /* Initialised in edittoolcode(). */
X NULL
X };
X
struct Gadget CCCCGadget7 = {
X NULL,
X 175,54,
X 80,11,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE,
X RELVERIFY|GADGIMMEDIATE,
X BOOLGADGET,
X (APTR)&CCCCBorder1,
X NULL,
X &CCCCIText1,
X NULL,
X NULL,
X CCCC_GRANULARITY_GADGET,
X NULL
X };
X
/* Direction gadget. */
SHORT CCCCBorderVectors2[] = {
X 0,0,
X 81,0,
X 81,12,
X 0,12,
X 0,0
};
struct Border CCCCBorder2 = {
X -1,-1,
X 3,0,JAM1,
X 5,
X CCCCBorderVectors2,
X NULL
X };
X
struct IntuiText CCCCIText2 = {
X 4,0,JAM1,
X 25,1,
X NULL,
X NULL, /* Initialised in edittoolcode(). */
X NULL
};
X
struct Gadget CCCCGadget6 = {
X &CCCCGadget7,
X 175,41,
X 80,11,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE,
X RELVERIFY|GADGIMMEDIATE,
X BOOLGADGET,
X (APTR)&CCCCBorder2,
X NULL,
X &CCCCIText2,
X NULL,
X NULL,
X CCCC_DIRECTION_GADGET,
X NULL
};
X
/* Wave gadget. */
SHORT CCCCBorderVectors3[] = {
X 0,0,
X 81,0,
X 81,12,
X 0,12,
X 0,0
};
struct Border CCCCBorder3 = {
X -1,-1,
X 3,0,JAM1,
X 5,
X CCCCBorderVectors3,
X NULL
};
X
struct IntuiText CCCCIText3 = {
X 4,0,JAM1,
X 10,1,
X NULL,
X NULL, /* Initialised in edittoolcode(). */
X NULL
};
X
struct Gadget CCCCGadget5 = {
X &CCCCGadget6,
X 175,28,
X 80,11,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE,
X RELVERIFY|GADGIMMEDIATE,
X BOOLGADGET,
X (APTR)&CCCCBorder3,
X NULL,
X &CCCCIText3,
X NULL,
X NULL,
X CCCC_WAVE_GADGET,
X NULL
X };
X
/* Period gadget. */
struct StringExtend replace_mode_string_gadget1 = {
X NULL,
X { 1, 0 },
X { 1, 0 },
X SGM_REPLACE|SGM_FIXEDFIELD,
X NULL,
X NULL,
X };
X
UBYTE CCCCCCCCGadget4SIBuff[MBC_STRING_LENGTH];
struct StringInfo CCCCCCCCGadget4SInfo = {
X CCCCCCCCGadget4SIBuff,
X NULL,
X 0,
X MBC_STRING_LENGTH,
X 0,
X 0,0,0,0,0,
X &replace_mode_string_gadget1,
X 0,
X NULL
};
X
SHORT CCCCBorderVectors4[] = {
X 0,0,
X 101,0,
X 101,12,
X 0,12,
X 0,0
};
X
struct Border CCCCBorder4 = {
X -1,-1,
X 3,0,JAM1,
X 5,
X CCCCBorderVectors4,
X NULL
};
X
struct IntuiText CCCCIText4 = {
X 2,0,JAM1,
X -57,0,
X NULL,
X "Period:",
X NULL
};
X
struct Gadget CCCCGadget4 = {
X &CCCCGadget5,
X 69,54,
X 100,11,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE|GFLG_STRINGEXTEND|GFLG_TABCYCLE,
X RELVERIFY|GADGIMMEDIATE,
X STRGADGET,
X (APTR)&CCCCBorder4,
X NULL,
X &CCCCIText4,
X NULL,
X (APTR)&CCCCCCCCGadget4SInfo,
X CCCC_PERIOD_GADGET,
X NULL
};
X
/* Finish gadget. */
struct StringExtend replace_mode_string_gadget2 = {
X NULL,
X { 1, 0 },
X { 1, 0 },
X SGM_REPLACE|SGM_FIXEDFIELD,
X NULL,
X NULL,
X };
X
UBYTE CCCCCCCCGadget3SIBuff[MBC_STRING_LENGTH];
struct StringInfo CCCCCCCCGadget3SInfo = {
X CCCCCCCCGadget3SIBuff,
X NULL,
X 0,
X MBC_STRING_LENGTH,
X 0,
X 0,0,0,0,0,
X &replace_mode_string_gadget2,
X 0,
X NULL
};
X
SHORT CCCCBorderVectors5[] = {
X 0,0,
X 101,0,
X 101,12,
X 0,12,
X 0,0
};
X
struct Border CCCCBorder5 = {
X -1,-1,
X 3,0,JAM1,
X 5,
X CCCCBorderVectors5,
X NULL
};
X
struct IntuiText CCCCIText5 = {
X 2,0,JAM1,
X -58,1,
X NULL,
X "Finish:",
X NULL
};
X
struct Gadget CCCCGadget3 = {
X &CCCCGadget4,
X 69,41,
X 100,11,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE|GFLG_STRINGEXTEND|GFLG_TABCYCLE,
X RELVERIFY|GADGIMMEDIATE,
X STRGADGET,
X (APTR)&CCCCBorder5,
X NULL,
X &CCCCIText5,
X NULL,
X (APTR)&CCCCCCCCGadget3SInfo,
X CCCC_FINISH_GADGET,
X NULL
X };
X
/* Start gadget. */
struct StringExtend replace_mode_string_gadget3 = {
X NULL,
X { 1, 0 },
X { 1, 0 },
X SGM_REPLACE|SGM_FIXEDFIELD,
X NULL,
X NULL,
X };
X
UBYTE CCCCCCCCGadget2SIBuff[MBC_STRING_LENGTH];
struct StringInfo CCCCCCCCGadget2SInfo = {
X CCCCCCCCGadget2SIBuff,
X NULL,
X 0,
X MBC_STRING_LENGTH,
X 0,
X 0,0,0,0,0,
X &replace_mode_string_gadget3,
X 0,
X NULL
};
X
SHORT CCCCBorderVectors6[] = {
X 0,0,
X 101,0,
X 101,12,
X 0,12,
X 0,0
};
X
struct Border CCCCBorder6 = {
X -1,-1,
X 3,0,JAM1,
X 5,
X CCCCBorderVectors6,
X NULL
};
X
struct IntuiText CCCCIText6 = {
X 2,0,JAM1,
X -58,1,
X NULL,
X "Start:",
X NULL
};
X
struct Gadget CCCCGadget2 = {
X &CCCCGadget3,
X 69,28,
X 100,11,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE|GFLG_STRINGEXTEND|GFLG_TABCYCLE,
X RELVERIFY|GADGIMMEDIATE,
X STRGADGET,
X (APTR)&CCCCBorder6,
X NULL,
X &CCCCIText6,
X NULL,
X (APTR)&CCCCCCCCGadget2SInfo,
X CCCC_START_GADGET,
X NULL
};
X
/* CC# gadget. */
struct PropInfo CCCCCCCCGadget1SInfo = {
X AUTOKNOB+FREEHORIZ,
X -16384, -1,
X 16384, -1,
};
X
struct Image CCCCImage1 = {
X 0,0,
X 102,6,
X 0,
X NULL,
X 0x0000,0x0000,
X NULL
};
X
struct IntuiText CCCCIText7 = {
X 2,0,JAM1,
X -58,1,
X NULL,
X "CC #:",
X NULL
};
X
struct Gadget CCCCGadget1 = {
X &CCCCGadget2,
X 69,14,
X 100,10,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE,
X RELVERIFY|GADGIMMEDIATE,
X PROPGADGET,
X (APTR)&CCCCImage1,
X NULL,
X &CCCCIText7,
X NULL,
X (APTR)&CCCCCCCCGadget1SInfo,
X CCCC_CC_GADGET,
X NULL
};
X
#define CCCCGadgetList1 CCCCGadget1
X
struct NewWindow CCCCNewWindowStructure1 = {
X 75,85,
X 265,70,
X 0,6,
X GADGETDOWN+GADGETUP+CLOSEWINDOW,
X WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCAREREFRESH,
X &CCCCGadget1,
X NULL,
X "CCCC",
X NULL,
X NULL,
X 5,5,
X -1,-1,
X CUSTOMSCREEN
};
X
/* Sets the text of the gadget to text. */
void
X setgadgettext(struct Window *window, /* Window where the gadget lives. */
X const short id, /* Gadget id. */
X const char *text) /* String to stick in gadget text. */
{
X struct Gadget *gadget = (struct Gadget *) (*functions->GetGadget)(window,id);
X if (gadget)
X {
X gadget->GadgetText->IText = text;
X (functions->DrawEmbossed)(window,id);
X }
}
X
/* Prints out the value associated with the CC# prop gadget. */
__geta4 /* Callback. */
long controller_routine(struct Window *window, /* Window where the gadget lives. */
X struct Gadget *gadget, /* The gadget itself. Unused. */
X unsigned long value) /* The value to display. */
{
X char text[10];
X struct RastPort *rp = window->RPort;
X Move(rp, 175, 21);
X SetAPen(rp, 1);
X SetBPen(rp, 0);
X SetDrMd(rp, JAM2);
X sprintf(text, "%3ld", value);
X Text(rp, text, 3);
X return value;
}
X
/* Converts a time value to a string and sets a string gadget with this
X information. */
static void
settimestring(struct Window *window, /* The window where the gadget lives. */
X short gadget, /* The id of the gadget to be set. */
X struct Clip *clip, /* The clip the time refers to. */
X long value, /* The new value. */
X char *string) /* Some storage for the conversion. */
{
X (*functions->timetostring)(clip, value, string);
X (*functions->SetStringInfo)(window, gadget, string);
}
X
/* Converts a length value to a string and sets a string gadget with this
X information. */
static void
setlengthstring(struct Window *window, /* The window where the gadget lives. */
X short gadget, /* The id of the gadget to be set. */
X struct Clip *clip, /* The clip the length refers to. */
X long start, /* The start time for the calculation. */
X long value, /* The length. */
X char *string) /* Some storage for the conversion. */
{
X (*functions->lengthtostring)(clip, start, value, string);
X (*functions->SetStringInfo)(window, gadget, string);
}
X
/* Update a gadget with a wave name. */
static void
setwave(struct Window *window, /* The window where the gadget lives. */
X short gadget, /* The id of the gadget to be updated. */
X enum Wave value) /* The wave value. */
{
X setgadgettext(window, gadget, wave_names[value]);
}
X
/* Update a gadget with a direction name. */
static void
setdirection(struct Window *window, /* The window where the gadget lives. */
X short gadget, /* The id of the gadget to be updated. */
X enum Direction direction) /* The direction value. */
{
X setgadgettext(window, gadget, direction_names[direction]);
}
X
/* Update a gadget with a note name. */
static void
setgranularity(struct Window *window, /* The window where the gadget lives. */
X short gadget, /* The id of the gadget to be updated. */
X long value) /* The index of the note name. */
{
X setgadgettext(window, gadget, note_names[value]);
}
X
/* Grab a time value from a string gadget. */
static long
updatetimestring(struct Window *window, /* The window where the gadget lives. */
X short id, /* The id of the gadget to be updated. */
X struct Clip *clip, /* The clip the time refers to. */
X long oldvalue) /* The old value this string gadget
X represented. */
{
X struct StringInfo *stringinfo =
X (struct StringInfo *)(*functions->GetStringInfo)(window, id);
X
X return (*functions->stringtotime)(clip, stringinfo->Buffer, oldvalue);
}
X
/* Grab a length value from a string gadget. */
static long
X updatelengthstring(struct Window *window, /* The window where the gadget lives. */
X short id, /* The id of the gadget to be updated. */
X struct Clip *clip, /* The clip the length refers to. */
X long start, /* The start time for the calculation. */
X long oldvalue) /* The old value this string
X gadget represented. */
{
X struct StringInfo *stringinfo =
X (struct StringInfo *)(*functions->GetStringInfo)(window, id);
X
X (*functions->stringtolength)(clip, start, stringinfo->Buffer, oldvalue);
}
X
/* Interface driver called by Bars and Pipes. */
__geta4 /* Callback. */
void edittoolcode(struct CCCCTool *tool)
{
X char *string[MBC_STRING_LENGTH];
X
X struct IntuiMessage *message;
X struct Window *window;
X long class, code;
X struct Gadget *gadget;
X struct NewWindow *newwindow;
X long refresh = 1;
X
X struct Clip *clip = tool->tool.track == NULL ? NULL : &(tool->tool.track->clip);
X
X if (!tool->tool.touched)
X {
X cccc_tool_init(tool);
X }
X
X CCCCNewWindowStructure1.Screen = functions->screen;
X
X if (tool->tool.touched & TOUCH_EDIT)
X {
X CCCCNewWindowStructure1.LeftEdge = tool->tool.left;
X CCCCNewWindowStructure1.TopEdge = tool->tool.top;
X }
X
X newwindow = (struct NewWindow *)
X (*functions->DupeNewWindow)(&CCCCNewWindowStructure1);
X if (!newwindow)
X {
X return;
X }
X newwindow->Title = 0;
X newwindow->Flags |= BORDERLESS;
X newwindow->Flags &= ~0xF;
X newwindow->BlockPen = 0;
X newwindow->DetailPen = 0;
X
X window = (struct Window *) (*functions->FlashyOpenWindow)(newwindow);
X if (window == NULL)
X {
X return;
X }
X
X tool->tool.window = window;
X
X /* Make the various gadgets look pretty. */
X (*functions->EmbossWindowOn)(window,WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG,
X CCCC_NAME, (short)-1, (short)-1, 0, 0);
X
X for (long i = CCCC_WAVE_GADGET;
X i <= CCCC_GRANULARITY_GADGET;
X i++)
X {
X (*functions->EmbossOn)(window, i, 0);
X }
X
X (*functions->FatEmbossedPropOn)(window,
X CCCC_CC_GADGET, CCCC_CCDOWN_GADGET,
X CCCC_CCUP_GADGET,
X (no_prototype) controller_routine,
X CC_VALUE_NUM, 1);
X
X (*functions->ModifyEmbossedProp)(window, CCCC_CC_GADGET,
X tool->controller, 0, 0, 0, 0, 0);
X
X (*functions->DrawEmbossedProp)(window, CCCC_CC_GADGET);
X
X /* Initialise the contents of the various gadgets. */
X settimestring(window, CCCC_START_GADGET,
X clip, tool->start, string);
X settimestring(window, CCCC_FINISH_GADGET,
X clip, tool->finish, string);
X setlengthstring(window, CCCC_PERIOD_GADGET,
X clip, tool->start, tool->period, string);
X
X setwave(window, CCCC_WAVE_GADGET, tool->wave);
X
X setdirection(window, CCCC_DIRECTION_GADGET, tool->direction);
X
X setgranularity(window, CCCC_GRANULARITY_GADGET, tool->granularity);
X
X /* Process messages until a CLOSEWINDOW. */
X for (;;)
X {
X message = (struct IntuiMessage *) (*functions->GetIntuiMessage)(window);
X class = message->Class;
X code = message->Code;
X gadget = (struct Gadget *) message->IAddress;
X class = (*functions->SystemGadgets)(window,class,gadget,code);
X
X ReplyMsg((struct Message *)message);
X
X if (class == CLOSEWINDOW)
X {
X break; /* ... out of the for(;;) loop. */
X }
X else if (class == GADGETDOWN)
X {
X const short id = gadget->GadgetID;
X switch (id)
X {
X case CCCC_CC_GADGET:
X tool->controller =
X (*functions->DragEmbossedProp)(window, CCCC_CC_GADGET);
X (*functions->DrawEmbossedProp)(window, CCCC_CC_GADGET);
X break;
X case CCCC_CCDOWN_GADGET:
X tool->controller =
X (*functions->ShiftEmbossedProp)(window, CCCC_CC_GADGET, -1, 0);
X (*functions->DrawEmbossedProp)(window, CCCC_CC_GADGET);
X break;
X case CCCC_CCUP_GADGET:
X tool->controller =
X (*functions->ShiftEmbossedProp)(window, CCCC_CC_GADGET, 1, 0);
X (*functions->DrawEmbossedProp)(window, CCCC_CC_GADGET);
X break;
X case CCCC_START_GADGET:
X settimestring(window, CCCC_START_GADGET,
X clip, tool->start, string);
X break;
X case CCCC_FINISH_GADGET:
X settimestring(window, CCCC_FINISH_GADGET,
X clip, tool->finish, string);
X break;
X case CCCC_PERIOD_GADGET:
X setlengthstring(window, CCCC_PERIOD_GADGET,
X clip, tool->start, tool->period, string);
X break;
X case CCCC_WAVE_GADGET:
X if (tool->wave == TRIANGLE2)
X {
X tool->wave = TRIANGLE;
X }
X else
X {
X tool->wave++;
X }
X setwave(window, CCCC_WAVE_GADGET, tool->wave);
X break;
X case CCCC_DIRECTION_GADGET:
X if (tool->direction == DOWN)
X {
X tool->direction = UP;
X }
X else
X {
X tool->direction++;
X }
X setdirection(window, CCCC_DIRECTION_GADGET, tool->direction);
X break;
X case CCCC_GRANULARITY_GADGET:
X {
X const int value = (*functions->popupnote)(window, tool->granularity);
X if (value != -1)
X {
X /* The tranposrt only sends out commands on beats, so it's
X pointless having a granularity of less then 2 (== 1/4). */
X if (value < 2)
X {
X tool->granularity = 2;
X }
X else
X {
X tool->granularity = value;
X }
X }
X setgranularity(window, CCCC_GRANULARITY_GADGET, tool->granularity);
X }
X break;
X }
X }
X else if (class == GADGETUP)
X {
X const short id = gadget->GadgetID;
X switch (id)
X {
X case CCCC_CC_GADGET:
X case CCCC_CCDOWN_GADGET:
X case CCCC_CCUP_GADGET:
X break;
X case CCCC_START_GADGET:
X /* Make sure start time is before finish time. */
X tool->start = updatetimestring(window, id, clip, tool->start);
X if (tool->start > tool->finish)
X {
X tool->start = tool->finish;
X }
X settimestring(window, CCCC_START_GADGET, clip,
X tool->start, string);
X break;
X case CCCC_FINISH_GADGET:
X /* Make sure finish time is after start time. */
X tool->finish = updatetimestring(window, id, clip, tool->finish);
X if (tool->finish < tool->start)
X {
X tool->finish = tool->start;
X }
X settimestring(window, CCCC_FINISH_GADGET, clip,
X tool->finish, string);
X break;
X case CCCC_PERIOD_GADGET:
X tool->period = updatelengthstring(window, id, clip, tool->start,
X tool->period);
X if (tool->period == 0)
X {
X tool->period = 1;
X }
X setlengthstring(window, CCCC_PERIOD_GADGET, clip,
X tool->start, tool->period, string);
X break;
X case CCCC_WAVE_GADGET:
X case CCCC_DIRECTION_GADGET:
X case CCCC_GRANULARITY_GADGET:
X break;
X }
X }
X }
X tool->tool.window = 0;
X tool->tool.left = window->LeftEdge;
X tool->tool.top = window->TopEdge;
X tool->tool.width = window->Width;
X tool->tool.height = window->Height;
X tool->tool.touched = TOUCH_INIT | TOUCH_EDIT;
X
X /* Turn off the prettiness. */
X (*functions->FatEmbossedPropOff)(window,
X CCCC_CC_GADGET, CCCC_CCDOWN_GADGET,
X CCCC_CCUP_GADGET);
X
X for (long i = CCCC_WAVE_GADGET;
X i <= CCCC_GRANULARITY_GADGET;
X i++)
X {
X (*functions->EmbossOff)(window, i);
X }
X
X (*functions->EmbossWindowOff)(window);
X (*functions->FlashyCloseWindow)(window);
X (*functions->DeleteNewWindow)(newwindow);
}
X
/* Process notes. */
__geta4 /* Callback. */
struct Event *
X processeventcode(struct Event *event)
{
X event->tool = event->tool->next; /* Doesn't do anything with the event. */
X
X return(event);
}
X
/* Make sure we remove the transport routine. */
__geta4 /* Callback. */
void removetool()
{
X (*functions->removetransport)(transportcode);
}
X
struct ToolMaster *
X inittoolmaster()
{
X memset((char *)&master,0,sizeof(struct ToolMaster));
X master.toolid = ID_CCCC;
X master.image = &cccc_image;
X strcpy(master.name, CCCC_NAME);
X master.edittool = (void_prototype) edittoolcode;
X master.tooltype = CCCC_TYPE;
X master.processevent = (event_prototype) processeventcode;
X master.removetool = removetool;
X master.toolsize = sizeof(struct CCCCTool);
X (*functions->installtransport)(transportcode);
X return(&master);
}
SHAR_EOF
chmod 0600 cccc.c ||
echo 'restore of cccc.c failed'
Wc_c="`wc -c < 'cccc.c'`"
test 24965 -eq "$Wc_c" ||
echo 'cccc.c: original size 24965, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= cccc.ptool ==============
if test -f 'cccc.ptool' -a X"$1" != X"-c"; then
echo 'x - skipping cccc.ptool (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting cccc.ptool (Binary)'
sed 's/^X//' << 'SHAR_EOF' > _shar_tmp_.tmp &&
begin 600 cccc.ptool
<encoded_portion_removed>
end
SHAR_EOF
echo 'uudecoding file cccc.ptool' &&
uudecode < _shar_tmp_.tmp && rm -f _shar_tmp_.tmp &&
chmod 0600 cccc.ptool ||
echo 'restore of cccc.ptool failed'
Wc_c="`wc -c < 'cccc.ptool'`"
test 5552 -eq "$Wc_c" ||
echo 'cccc.ptool: original size 5552, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= cccc.readme ==============
if test -f 'cccc.readme' -a X"$1" != X"-c"; then
echo 'x - skipping cccc.readme (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting cccc.readme (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'cccc.readme' &&
Short: Bars & Pipes Tool for generating cyclically varying control changes.
Author: Richard Hagen (R.H...@mailbox.uq.edu.au)
Uploader: Richard Hagen (R.H...@mailbox.uq.edu.au)
Version: 1.3 (22 September 1997)
Type: mus/midi
Requires: Bars and Pipes Professional
Distribution: Freely distributable by anyone, anywhere.
URL: http://www.it.uq.edu.au/~richard/music/bars-and-pipes/index.html
X
CCCC: A Bars and Pipes Tool for generating cyclically varying control
X change messages.
X
Version: 1.3 (22 September 1997)
X
Author: Richard Hagen
X R.H...@mailbox.uq.edu.au
X
Distribution: Freeware. See the copyright notice in cccc.c.
X
Requirements for running:
X Bars and Pipes Professional
X
Requirements for recompiling:
X DICE (or some other C compiler)
X bars.h and toolstart.c from the Rules for Tools kit.
X
Usage:
X CCCC generates events, but can be used anywhere in pipelines.
X It can't be used as a padtool.
X
X Several gadgets control the functioning of CCCC:
X
X CC# (proportional gadget, range [0 .. 127])
X This is the number of the control change that you want
X produce messages for. CC# defaults to 10, the control
X for panning.
X Start (string gadget)
X This is the time (Measure.Beat.Clock) when CCCC should start
X producing messages. If you try to enter a start value
X that is greater than the finish value, the start value
X is set to the finish value. Start defaults to 1.1.0
X (i.e. time == 0).
X Finish (string gadget)
X This is the time (M.B.C) when CCCC should finish
X producing messages. If you try to enter a finish value that
X is less than the start value, the finish value will be
X set to the start value. Finish defaults to the time of the
X stop marker for the current song.
X Period: (string gadget)
X This is the length (M.B.C) of the oscillation of
X the control change value. The period can't be set
X to less than one clock. Period defaults to 1.0.0
X (i.e. 768 clocks).
X Wave (cycle gadget)
X This is the function that generates the oscillation.
X Currently, you can choose one of TRIANGLE, SAW, SQUARE,
X RANDOM or TRIANGLE2 waves. The best way to understand
X these waveforms is to watch them in action! Wave defaults
X to TRIANGLE.
X Direction (cycle gadget)
X This is the initial direction of the wave function, UP or
X DOWN. Direction defaults to UP.
X Granularity (Bars and Pipes ``pop up note'' gadget)
X This defines how often control change messages are
X output by CCCC. The valid granularities are 1/4,
X 1/8, 1/16, 1/32 and 1/64 notes; whole and half note
X granularities are difficult to generate, due to the
X timing of Bars and Pipes transport messages, so
X if you select them they're automatically
X translated down to 1/4 note granularity.
X
X When a CCCC window is open, and CCCC is producing control
X change messages, the control change value of the last message
X generated is displayed in the top right hand corner. Since
X CCCC generates batches of messages before their output time,
X values will be shown a little ahead of the their actual passage
X through the pipeline. Don't be alarmed: this is how the Bars
X and Pipes transport works - by creating batches of events ahead
X of time, and sorting out their exact timing only when needed.
X
Useful for:
X Everything! Use it as an LFO. Combined with the Event Mapper
X and my control change Scaler, you can generate any sort of voice
X control messages for any purpose: Pitch Bends, Filter Sweeps,
X Sample Start/Loop Point Modulation, .... Anything!
X
History:
X Version 1.3 (22 September 1997)
X Added TRIANGLE2 waveform. Made it a TOOL_NORMAL tool.
X
X Version 1.2 (13 September 1997)
X Redrew icon. Added the tool type NOTPAD.
X
X Version 1.1 (9 September 1997)
X Made sure the period couldn't be zero clocks.
X
X Version 1.0 (8 September 1997)
X Initial release.
X
If you like this tool, please drop me a line.
X
richard
R.H...@mailbox.uq.edu.au
22 September 1997
X
SHAR_EOF
chmod 0600 cccc.readme ||
echo 'restore of cccc.readme failed'
Wc_c="`wc -c < 'cccc.readme'`"
test 3885 -eq "$Wc_c" ||
echo 'cccc.readme: original size 3885, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= dmakefile ==============
if test -f 'dmakefile' -a X"$1" != X"-c"; then
echo 'x - skipping dmakefile (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting dmakefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'dmakefile' &&
#
# The name of the tool.
#
TOOL = cccc
X
#
# The source files that you need to build the tool.
#
MYSRCS = cccc.c
X
MYHDRS = myheader.h
X
#
# You might want to tinker with the compiler flags and libraries.
#
# -3.0 - Compile for a 3.0 system (optional)
# -mc - Small code model
# -md - Small data model
#
CFLAGS = -3.0 -mc -md
X
#
# Required libraries
#
# amiga30s.lib - The small code version of the Amiga library
# cs.lib - The small code version of the C library
# ms.lib - The small code version of the maths library
#
LIBS = amiga30s.lib cs.lib ms.lib
X
#
# You shouldn't have to touch anything below here.
#
# (FYI: (It's important that toolstart.c gets listed first... toolstart.o
# has to be the first thing mentioned when the tool is linked
# together.)
#
PTOOL = $(TOOL).ptool
README = $(TOOL).readme
ARCHIVE = $(TOOL).lha
X
SRCS = toolstart.c $(MYSRCS)
OBJS = $(SRCS:*.c:*.o)
X
all: $(PTOOL)
X
$(PTOOL): $(OBJS)
X dlink $(OBJS) $(LIBS) -o $(PTOOL)
X
$(OBJS): $(SRCS)
X dcc $(CFLAGS) -c %(right) -o %(left)
X
# I use emacs, so I tend to have a lot of backup files ending in ``!''
# lying around.
clean:
X delete $(OBJS) *!
X
clobber: clean
X delete $(PTOOL) $(ARCHIVE)
X
distribution: $(ARCHIVE)
X
$(ARCHIVE): clobber $(PTOOL) clean
X lha a $(ARCHIVE) dmakefile $(PTOOL) $(MYHDRS) $(MYSRCS) $(README)
X
X
X
SHAR_EOF
chmod 0600 dmakefile ||
echo 'restore of dmakefile failed'
Wc_c="`wc -c < 'dmakefile'`"
test 1299 -eq "$Wc_c" ||
echo 'dmakefile: original size 1299, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= myheader.h ==============
if test -f 'myheader.h' -a X"$1" != X"-c"; then
echo 'x - skipping myheader.h (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting myheader.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'myheader.h' &&
/*
X myheader.h - Useful #defines and typedefs for tool/accessory programs.
*/
X
#ifndef MYHEADER_H
#define MYHEADER_H
X
/* Length of tool/accessory id. */
#define ID_LEN 4
X
/* Make an id out of four characters. */
#define MAKE_ID(a, b, c, d) ((ULONG) ((((a << 8) + b << 8) + c << 8) + d))
X
/* Make an id out of a string. */
#define MAKE_IDS(s) (MAKE_ID(s[0], s[1], s[2], s[3]))
X
/* Split an id into four characters. */
#define SPLIT_ID(id, a, b, c, d) \
do { \
X a = (UBYTE) ((id >> 24) & 0xff); \
X b = (UBYTE) ((id >> 16) & 0xff); \
X c = (UBYTE) ((id >> 8) & 0xff); \
X d = (UBYTE) (id & 0xff); \
} while (0)
X
/* Split an id into a string. */
#define SPLIT_IDS(id, s) \
do { \
X SPLIT_ID(id, s[0], s[1], s[2], s[3]); \
} while (0)
X
/* Maximum MIDI note # */
#define MIDI_NOTE_MAX (127)
X
/* Number of MIDI notes. */
#define MIDI_NOTE_NUM (MIDI_NOTE_MAX + 1)
X
/* Maximum program change number. */
#define PC_CHANGE_MAX 127
X
/* Number of program changes. */
#define PC_CHANGE_NUM (PC_CHANGE_MAX + 1)
X
/* Maximum CC value. */
#define CC_VALUE_MAX 127
X
/* Number of CC values. */
#define CC_VALUE_NUM (CC_VALUE_MAX + 1)
X
/* Flags for use in the BRB file requester. */
#define FILES_DELETE 1 /* Delete button */
#define FILES_OPEN 2 /* Open button */
#define FILES_SAVE 4 /* Save button */
#define FILES_TEST 8 /* ??? */
#define FILES_TYPE 16 /* Type string gadget */
#define FILES_PATH 32 /* Path string gadget */
X
/* Initial placement of tool/accessory windows. */
#define INITIAL_LEFT 50
#define INITIAL_TOP 50
X
/* Unprototyping cast. */
typedef __geta4 long (*no_prototype)();
X
/* Void cast. */
typedef __geta4 void (*void_prototype)();
X
/* Event *cast. */
typedef __geta4 struct Event *(*event_prototype)();
X
/* For non-stdio debugging messages. */
#define DEBUG(message) \
do { \
X struct EasyStruct es = { \
X sizeof(struct EasyStruct), \
X 0, \
X "Debugging information", \
X "Message: %s", \
X "OK" \
X }; \
X (void) EasyRequest(functions->window, &es, 0, message); \
} while (0)
X
#define NOTE_LENGTH(x) (768 >> (x))
X
#define MBC_STRING_LENGTH 12
X
#define CLOCKSPERMEASURE 768L
X
#define STREQ(x, y) (strcmp((x), (y)) == 0)
#define STREQN(x, y, n) (strncmp((x), (y), (n)) == 0)
X
#endif /* MYHEADER_H */
SHAR_EOF
chmod 0600 myheader.h ||
echo 'restore of myheader.h failed'
Wc_c="`wc -c < 'myheader.h'`"
test 2288 -eq "$Wc_c" ||
echo 'myheader.h: original size 2288, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
exit 0
--
Bill Zimmer - z...@ibx.com

0 new messages