Browse Source

New StreamerButton, MousePlugin (First Stage), Bits and Bobs

master
edgeeffect 22 years ago
parent
commit
1246bbaea5
16 changed files with 798 additions and 83 deletions
  1. +5
    -7
      SpiralSound/Plugins/LFOPlugin/LFOPlugin.C
  2. +2
    -6
      SpiralSound/Plugins/LFOPlugin/LFOPlugin.h
  3. +4
    -4
      SpiralSound/Plugins/LFOPlugin/LFOPluginGUI.C
  4. +5
    -5
      SpiralSound/Plugins/LFOPlugin/LFOPluginGUI.h
  5. +5
    -6
      SpiralSound/Plugins/MeterPlugin/MeterPlugin.C
  6. +3
    -4
      SpiralSound/Plugins/MixerPlugin/MixerPlugin.h
  7. +162
    -0
      SpiralSound/Plugins/MousePlugin/Makefile.in
  8. +123
    -0
      SpiralSound/Plugins/MousePlugin/MousePlugin.C
  9. +67
    -0
      SpiralSound/Plugins/MousePlugin/MousePlugin.h
  10. +68
    -0
      SpiralSound/Plugins/MousePlugin/MousePluginGUI.C
  11. +55
    -0
      SpiralSound/Plugins/MousePlugin/MousePluginGUI.h
  12. +43
    -0
      SpiralSound/Plugins/MousePlugin/SpiralIcon.xpm
  13. +133
    -0
      SpiralSound/Plugins/MousePlugin/scratch.C
  14. +54
    -0
      SpiralSound/Plugins/MousePlugin/scratch.h
  15. +59
    -42
      SpiralSound/Plugins/StreamPlugin/StreamPluginGUI.C
  16. +10
    -9
      SpiralSound/Plugins/StreamPlugin/StreamPluginGUI.h

+ 5
- 7
SpiralSound/Plugins/LFOPlugin/LFOPlugin.C View File

@@ -22,16 +22,15 @@
#include "SpiralIcon.xpm"

extern "C" {

SpiralPlugin* SpiralPlugin_CreateInstance() { return new LFOPlugin; }

char** SpiralPlugin_GetIcon() { return SpiralIcon_xpm; }

int SpiralPlugin_GetID() { return 124; }

string SpiralPlugin_GetGroupName()
{
return "Oscillators";
}
string SpiralPlugin_GetGroupName() { return "Oscillators"; }

}

///////////////////////////////////////////////////////
@@ -50,9 +49,8 @@ m_TableLength (DEFAULT_TABLE_LEN) {
m_PluginInfo.PortTips.push_back ("Output");
m_PluginInfo.PortTips.push_back ("'Cosine' Output");
m_PluginInfo.PortTips.push_back ("Inverted Output");
m_AudioCH->Register("Freq",&m_Freq);
m_AudioCH->Register("Type",(char*)&m_Type);
m_AudioCH->Register("Freq", &m_Freq);
m_AudioCH->Register("Type", (char*)&m_Type);
}

LFOPlugin::~LFOPlugin() {


+ 2
- 6
SpiralSound/Plugins/LFOPlugin/LFOPlugin.h View File

@@ -34,17 +34,13 @@ class LFOPlugin : public SpiralPlugin {
virtual void Execute();
virtual void StreamOut (ostream &s);
virtual void StreamIn (istream &s);
typedef char Type;
enum {SINE, TRIANGLE, SQUARE, SAW};
//typedef char Type;
enum Type {SINE, TRIANGLE, SQUARE, SAW};
void WriteWaves();
void NoteTrigger (int V, int s, int v);
float GetFreq() { return m_Freq; }
Type GetType() { return m_Type; }
private:
float AdjustPos (float pos);
// Voice specific parameter
int m_Note;


+ 4
- 4
SpiralSound/Plugins/LFOPlugin/LFOPluginGUI.C View File

@@ -169,7 +169,7 @@ void LFOPluginGUI::cb_NumFreq (Fl_Knob* o, void* v) {
// Callbacks for waveform buttons
inline void LFOPluginGUI::cb_Sine_i (Fl_LED_Button* o, void* v) {
m_GUICH->Set("Type", (char)(LFOPlugin::SINE));
m_GUICH->Set("Type", LFOPlugin::SINE);
}
void LFOPluginGUI::cb_Sine(Fl_LED_Button* o, void* v) {
((LFOPluginGUI*)(o->parent()))->cb_Sine_i (o, v);
@@ -177,7 +177,7 @@ void LFOPluginGUI::cb_Sine(Fl_LED_Button* o, void* v) {
inline void LFOPluginGUI::cb_Tri_i (Fl_LED_Button* o, void* v) {
m_GUICH->Set("Type",(char)(LFOPlugin::TRIANGLE));
m_GUICH->Set("Type", LFOPlugin::TRIANGLE);
}
void LFOPluginGUI::cb_Tri (Fl_LED_Button* o, void* v) {
((LFOPluginGUI*)(o->parent()))->cb_Tri_i (o, v);
@@ -185,7 +185,7 @@ void LFOPluginGUI::cb_Tri (Fl_LED_Button* o, void* v) {
inline void LFOPluginGUI::cb_Square_i (Fl_LED_Button* o, void* v) {
m_GUICH->Set("Type",(char)(LFOPlugin::SQUARE));
m_GUICH->Set("Type", LFOPlugin::SQUARE);
}
void LFOPluginGUI::cb_Square (Fl_LED_Button* o, void* v) {
((LFOPluginGUI*)(o->parent()))->cb_Square_i (o, v);
@@ -193,7 +193,7 @@ void LFOPluginGUI::cb_Square (Fl_LED_Button* o, void* v) {
inline void LFOPluginGUI::cb_Saw_i (Fl_LED_Button* o, void* v) {
m_GUICH->Set("Type",(LFOPlugin::SAW));
m_GUICH->Set("Type", LFOPlugin::SAW);
}
void LFOPluginGUI::cb_Saw (Fl_LED_Button* o, void* v) {
((LFOPluginGUI*)(o->parent()))->cb_Saw_i (o, v);


+ 5
- 5
SpiralSound/Plugins/LFOPlugin/LFOPluginGUI.h View File

@@ -16,8 +16,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef LFOGUI
#define LFOGUI
#ifndef LFO_GUI_H
#define LFO_GUI_H
#include <FL/Fl_Pixmap.H>
#include <FL/Fl_Tabs.H>
@@ -29,10 +29,10 @@
class LFOPluginGUI : public SpiralPluginGUI {
public:
LFOPluginGUI(int w, int h, LFOPlugin *o,ChannelHandler *ch,const HostInfo *Info);
virtual void UpdateValues(SpiralPlugin *o);
LFOPluginGUI (int w, int h, LFOPlugin *o, ChannelHandler *ch, const HostInfo *Info);
virtual void UpdateValues (SpiralPlugin *o);
protected:
const string GetHelpText(const string &loc);
const string GetHelpText (const string &loc);
private:
Fl_Tabs *m_TheTabs;
Fl_Group *m_CtlGroup, *m_NumGroup;


+ 5
- 6
SpiralSound/Plugins/MeterPlugin/MeterPlugin.C View File

@@ -27,13 +27,13 @@ char** SpiralPlugin_GetIcon() { return SpiralIcon_xpm; }

int SpiralPlugin_GetID() { return 123; }

string SpiralPlugin_GetGroupName()
{
return "Control";
}
string SpiralPlugin_GetGroupName() { return "Control"; }

}

MeterPlugin::MeterPlugin() {
MeterPlugin::MeterPlugin():
m_Data (NULL)
{
m_PluginInfo.Name = "Meter";
m_PluginInfo.Width = 230;
m_PluginInfo.Height = 128;
@@ -41,7 +41,6 @@ MeterPlugin::MeterPlugin() {
m_PluginInfo.NumOutputs = 1;
m_PluginInfo.PortTips.push_back ("Input");
m_PluginInfo.PortTips.push_back ("Output");
m_Data = NULL;
}

MeterPlugin::~MeterPlugin() {


+ 3
- 4
SpiralSound/Plugins/MixerPlugin/MixerPlugin.h View File

@@ -16,11 +16,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "../SpiralPlugin.h"
//#include <FL/Fl_Pixmap.H>
#ifndef MIXER_PLUGIN_H
#define MIXER_PLUGIN_H

#ifndef MixerPLUGIN
#define MixerPLUGIN
#include "../SpiralPlugin.h"

static const int MAX_CHANNELS = 16;



+ 162
- 0
SpiralSound/Plugins/MousePlugin/Makefile.in View File

@@ -0,0 +1,162 @@
#############################################################################
# Makefile for building MousePlugin.so
#############################################################################

####### Compiler, tools and options

CC = gcc
CXX = g++
CFLAGS = @CFLAGS@
CXXFLAGS= @CXXFLAGS@
INCPATH = -I/usr/X11R6/include
LINK = g++ -shared
LFLAGS =
LIBS = -L/usr/X11R6/lib @FLTK_LIBS@ -lGL -lXext -lX11 -ldl
MOC = moc
UIC =

TAR = tar -cf
GZIP = gzip -9f

INSTALL = @INSTALL@

###### Autoconf variables

prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@

####### Files

HEADERS = ../SpiralPlugin.h \
../SpiralPluginGUI.h \
MousePlugin.h \
MousePluginGUI.h \
../../Sample.h \
../../ChannelHandler.h \
../../../GUI/Widgets/SpiralGUI.H \
scratch.h
SOURCES = ../SpiralPlugin.C \
../SpiralPluginGUI.C \
MousePlugin.C \
MousePluginGUI.C \
../../Sample.C \
../../ChannelHandler.C \
../../../GUI/Widgets/SpiralGUI.C \
scratch.C
OBJECTS = ../SpiralPlugin.o \
../SpiralPluginGUI.o \
MousePlugin.o \
MousePluginGUI.o \
../../Sample.o \
../../ChannelHandler.o \
../../../GUI/Widgets/SpiralGUI.o \
scratch.o
INTERFACES =
UICDECLS =
UICIMPLS =
SRCMOC =
OBJMOC =
DIST =
TARGET = MousePlugin.so

####### Implicit rules

.SUFFIXES: .cpp .cxx .cc .C .c

.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<

####### Build rules

all: $(TARGET)

$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)

moc: $(SRCMOC)

dist:
$(TAR) MousePlugin.tar $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST)
$(GZIP) MousePlugin.tar

clean:
-rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) $(TARGET)
-rm -f *~ core

install:
$(INSTALL) $(TARGET) $(libdir)/SpiralPlugins

####### Sub-libraries


###### Combined headers


####### Compile

../SpiralPlugin.o: ../SpiralPlugin.C \
../SpiralPlugin.h \
../../Sample.h

../SpiralPluginGUI.o: ../SpiralPluginGUI.C \
../SpiralPlugin.h \
../SpiralPluginGUI.h \
../../../GUI/Widgets/SpiralGUI.H \
../../Sample.h

../../../GUI/Widgets/SpiralGUI.o: ../../../GUI/Widgets/SpiralGUI.C \
../../../GUI/Widgets/SpiralGUI.H

../../Sample.o: ../../Sample.C \
../../Sample.h \
../../SpiralInfo.h

MousePlugin.o: MousePlugin.C \
MousePlugin.h \
MousePluginGUI.h \
../SpiralPlugin.h \
../SpiralPluginGUI.h \
../../SpiralInfo.h \
../../Sample.h \
scratch.h \
SpiralIcon.xpm

MousePluginGUI.o: MousePluginGUI.C \
MousePluginGUI.h \
MousePlugin.h \
../SpiralPluginGUI.h \
../SpiralPlugin.h \
../../../GUI/Widgets/SpiralGUI.H \
../../SpiralInfo.h \
../../Sample.h \
scratch.h

../../ChannelHandler.o: ../../ChannelHandler.C \
../../ChannelHandler.h

scratch.o: scratch.C \
scratch.h


+ 123
- 0
SpiralSound/Plugins/MousePlugin/MousePlugin.C View File

@@ -0,0 +1,123 @@
/* MousePlugin
* Copyleft (C) 2002 Dan Bethell <dan@pawfal.org>
* Dave Griffiths <dave@pawfal.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/


#define SCRATCH_DEVICE "/dev/ttyS1"

#include "MousePlugin.h"
#include "MousePluginGUI.h"
#include "SpiralIcon.xpm"

extern "C" {

SpiralPlugin* SpiralPlugin_CreateInstance() { return new MousePlugin; }

char** SpiralPlugin_GetIcon() { return SpiralIcon_xpm; }

int SpiralPlugin_GetID() { return 300; }

string SpiralPlugin_GetGroupName() { return "InputOutput"; }

}

///////////////////////////////////////////////////////

//static const HostInfo* host;

MousePluginSingleton* MousePluginSingleton::m_Singleton = NULL;

int MousePlugin::m_RefCount=0;

///////////////////////////////////////////////////////

MousePluginSingleton::MousePluginSingleton() {
scr = new scratch(SCRATCH_DEVICE); // create scratch object
}

MousePluginSingleton::~MousePluginSingleton() {
if (scr!=NULL) {
delete scr;
}
}

///////////////////////////////////////////////////////

MousePlugin::MousePlugin():
m_Data (0.0)
{
m_RefCount++;
m_PluginInfo.Name = "Mouse";
m_PluginInfo.Width = 70;
m_PluginInfo.Height = 125;
m_PluginInfo.NumInputs = 1;
m_PluginInfo.NumOutputs = 1;
m_PluginInfo.PortTips.push_back ("Trigger");
m_PluginInfo.PortTips.push_back ("Output");
}

MousePlugin::~MousePlugin() {
m_RefCount--;
if (m_RefCount==0) {
MousePluginSingleton::PackUpAndGoHome();
}
}

PluginInfo &MousePlugin::Initialise (const HostInfo *Host) {
PluginInfo& Info = SpiralPlugin::Initialise (Host);
m_AudioCH->Register ("Data", &m_Data, ChannelHandler::OUTPUT);
return Info;
}

SpiralGUIType *MousePlugin::CreateGUI() {
return new MousePluginGUI (m_PluginInfo.Width, m_PluginInfo.Height, this, m_AudioCH, m_HostInfo);
}

void MousePlugin::Execute() {
float trigger = 1.0;
if (GetOutputBuf(0)) {
if (InputExists(0)) {
trigger = GetInput(0,0);
}
char c = MousePluginSingleton::Get()->getScr()->getData();
if (c!=0x0) {
float val;
int ch = (int)c;
val = (float)(ch / 127.00);
if (val>1) val=1;
if (val<-1) val=-1;
if (trigger>0) {
GetOutputBuf(0)->Set (val);
m_Data = val;
} else {
GetOutputBuf(0)->Set (m_Data);
}
} else {
GetOutputBuf(0)->Set (m_Data);
}
}
}

void MousePlugin::StreamOut (ostream &s) {
s << m_Version;
}

void MousePlugin::StreamIn (istream &s) {
int Version;
s >> Version;
}

+ 67
- 0
SpiralSound/Plugins/MousePlugin/MousePlugin.h View File

@@ -0,0 +1,67 @@
/* MousePlugin
* Copyleft (C) 2002 Dan Bethell <dan@pawfal.org>
* Dave Griffiths <dave@pawfal.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef MousePlugin_H
#define MousePlugin_H

#include "../SpiralPlugin.h"
#include "scratch.h"

class MousePluginSingleton {
public:
static MousePluginSingleton *Get() {
if (!m_Singleton) m_Singleton = new MousePluginSingleton;
return m_Singleton;
}
static void PackUpAndGoHome() {
if (m_Singleton) {
delete m_Singleton;
m_Singleton=NULL;
}
}
~MousePluginSingleton();
scratch *getScr() { return scr; }
private:
MousePluginSingleton();
scratch *scr;
static MousePluginSingleton* m_Singleton;
int count;
};

class MousePlugin : public SpiralPlugin {
public:
MousePlugin();
virtual ~MousePlugin();
virtual PluginInfo& Initialise (const HostInfo *Host);
virtual SpiralGUIType* CreateGUI();
virtual void Execute();
virtual void StreamOut (ostream &s);
virtual void StreamIn (istream &s);
//float getData() { return data; }
private:
static int m_RefCount;
float m_Data;
friend istream &operator>> (istream &s, MousePlugin &o);
friend ostream &operator<< (ostream &s, MousePlugin &o);
};

istream &operator>> (istream &s, MousePlugin &o);
ostream &operator<< (ostream &s, MousePlugin &o);

#endif

+ 68
- 0
SpiralSound/Plugins/MousePlugin/MousePluginGUI.C View File

@@ -0,0 +1,68 @@
/* MousePlugin
* Copyleft (C) 2002 Dan Bethell <dan@pawfal.org>
* Dave Griffiths <dave@pawfal.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "MousePluginGUI.h"
#include <FL/fl_draw.h>
#include <FL/fl_draw.H>

static const int GUI_COLOUR = 154;
static const int GUIBG_COLOUR = 144;
static const int GUIBG2_COLOUR = 145;

ScratchWidget::ScratchWidget (int x, int y, int w, int h, const char *l, int BUFSIZE) :
Fl_Widget (x, y, w, h, l),
m_Data (0.0),
m_Channels (1),
m_Bufsize (BUFSIZE)
{
}

void ScratchWidget::draw() {
fl_color (GUIBG_COLOUR);
fl_rectf (x(), y(), w(), h());
fl_push_clip (x(), y(), w(), h());
int val = (int)(((m_Data * -1) + 1) * (h() / 2.0));
fl_color (FL_WHITE);
fl_rectf (x(), y() + val, w(), h());
fl_pop_clip();
}

////////////////////////////////////////////

MousePluginGUI::MousePluginGUI (int w, int h, MousePlugin *o, ChannelHandler *ch, const HostInfo *Info) :
SpiralPluginGUI (w, h, o, ch)
{
m_Scope = new ScratchWidget (5, 20, 60, 100, "Scratch", Info->BUFSIZE);
end();
}

void MousePluginGUI::Update () {
m_Scope->m_Data = m_GUICH->GetFloat ("Data");
m_Scope->redraw();
}

// Update GUI on Load
void MousePluginGUI::UpdateValues (SpiralPlugin* o) {
}

const string MousePluginGUI::GetHelpText (const string &loc) {
return string("")
+ "\n"
+ "\n";
}

+ 55
- 0
SpiralSound/Plugins/MousePlugin/MousePluginGUI.h View File

@@ -0,0 +1,55 @@
/* MousePlugin
* Copyleft (C) 2002 Dan Bethell <dan@pawfal.org>
* Dave Griffiths <dave@pawfal.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef MouseGUI_H
#define MouseGUI_H

#include <FL/Fl.H>
#include "MousePlugin.h"
#include "../SpiralPluginGUI.h"

class ScratchWidget : public Fl_Widget {
public:
ScratchWidget (int x, int y, int w, int h, const char *l, int BUFSIZE);
void draw();
void SetNumChannels (int s) { m_Channels = s; }
float m_Data;
int m_Channels;
private:
int m_GUIColour;
int m_GUIBGColour;
int m_Bufsize;
};

class MousePluginGUI : public SpiralPluginGUI {
public:
MousePluginGUI (int w, int h, MousePlugin *o, ChannelHandler *ch, const HostInfo *Info);
virtual void UpdateValues (SpiralPlugin *o);
virtual void Update ();
protected:
const string GetHelpText (const string &loc);
private:
// virtual void draw();
// void Display(float data);
// virtual SpiralPlugin* GetPlugin() { return m_Plugin; }
// MousePlugin *m_Plugin;
ScratchWidget *m_Scope;
};

#endif

+ 43
- 0
SpiralSound/Plugins/MousePlugin/SpiralIcon.xpm View File

@@ -0,0 +1,43 @@
/* XPM */
static char * SpiralIcon_xpm[] = {
"36 36 4 1",
" c None",
". c #000000",
"+ c #6E6E6E",
"@ c #FFFFFF",
" ",
" ",
" ",
" ............................. ",
" ............................. ",
" ............................. ",
" ...+++++++++++++++++++++++... ",
" ...+++++++++++++++++++++++... ",
" ...+++++++++++++++++++++++... ",
" ...+++++++++++++++++++++++... ",
" ...+++++++++++++++++++++++... ",
" ...++++++@@@@@@@@@@@@@@+++... ",
" ...++++++@@@@@@@++++++++++... ",
" ...++++++@@@@@@@++++++++++... ",
" ...++++++++@++++++++++++++... ",
" ...++...................++... ",
" ...+++++++++++++++++++++++... ",
" ...+++++++++++++++++++++++... ",
" ...+++++++++++++++++++++++... ",
" ...+++++++++++++++++++++++... ",
" ............................. ",
" ............................. ",
" ............................. ",
" ........ ",
" ........ ",
" ........ ",
" ........ ",
" ........ ",
" ............................. ",
" ............................. ",
" ............................. ",
" ............................. ",
" ............................. ",
" ............................. ",
" ",
" "};

+ 133
- 0
SpiralSound/Plugins/MousePlugin/scratch.C View File

@@ -0,0 +1,133 @@
/* MousePlugin
* Copyleft (C) 2002 Dan Bethell <dan@pawfal.org>
* Dave Griffiths <dave@pawfal.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "scratch.h"

#define BAUDRATE B1200
#define _POSIX_SOURCE 1 /* POSIX compliant source */
#define FALSE 0
#define TRUE 1

int c, res;
int count, total;
volatile int STOP=FALSE;
int fd; // the serial port device
struct termios oldtio,newtio;
unsigned char buf[3];
char *MODEMDEVICE;

scratch::scratch(char *dev)
{
openSerialPort(dev);
pthread_mutex_init( &mutex, NULL);
pthread_create( &scratch_thread, NULL, (void *(*)(void *))listen, this);
}

scratch::~scratch()
{
closeSerialPort();
}

void scratch::setData(char c)
{
pthread_mutex_lock( &mutex );
data = c;
pthread_mutex_unlock( &mutex );
}

char scratch::getData()
{
char result;
pthread_mutex_lock( &mutex );
result = data;
pthread_mutex_unlock( &mutex );
return result;
}

void scratch::stop()
{
pthread_mutex_lock( &mutex );
STOP=TRUE;
pthread_mutex_unlock( &mutex );
}

void openSerialPort(char *dev)
{
char *MODEMDEVICE = dev;

fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
if (fd <0)
{
perror(MODEMDEVICE); exit(-1);
}
tcgetattr(fd,&oldtio); /* save current port settings */
bzero(&newtio, sizeof(newtio));
newtio.c_cflag = BAUDRATE | CS7 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
/* set input mode (non-canonical, no echo,...) */
newtio.c_lflag = 0;
newtio.c_cc[VTIME] = 0; /* inter-character timer unused */
newtio.c_cc[VMIN] = 3; /* blocking read until 5 chars received */
tcflush(fd, TCIFLUSH);
tcsetattr(fd,TCSANOW,&newtio);
}

void closeSerialPort()
{
tcsetattr(fd,TCSANOW,&oldtio); // reset serial port settings
close(fd); // close pipe to serial port
}

void listen(scratch *scr)
{
while (STOP==FALSE)
{ /* loop for input */
res = read(fd,buf,3); /* returns after 3 chars have been input */
if (buf[0]>>6&1)
{
char c;
c = ((buf[0]&12)<<4)|(buf[2]&63);
if (c!=0x0) {
scr->setData(c);
// some random logging stuff
/*
total += (int)c;
count ++;
if (count%20==0) {
FILE *ptr = fopen("/tmp/EYEMUSH.log", "a+");
fprintf(ptr, "EYEMUSH LOG:\tScratch\n");
fclose(ptr);
}
*/
}
}
else
{
read(fd,buf,1);
}
}
}

+ 54
- 0
SpiralSound/Plugins/MousePlugin/scratch.h View File

@@ -0,0 +1,54 @@
/* MousePlugin
* Copyleft (C) 2002 Dan Bethell <dan@pawfal.org>
* Dave Griffiths <dave@pawfal.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef SCRATCH_H
#define SCRATCH_H

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <termios.h>
#include <stdio.h>
#include <iostream.h>
#include <pthread.h>

class scratch
{
public:
scratch(char *dev);
~scratch();
void setData(char c);
char getData();
void stop();
private:
pthread_t scratch_thread;
pthread_mutex_t mutex;
char data;
};

void openSerialPort(char *dev);
void closeSerialPort();
void listen(scratch *scr);

#endif

+ 59
- 42
SpiralSound/Plugins/StreamPlugin/StreamPluginGUI.C View File

@@ -25,6 +25,7 @@

StreamPluginGUI::StreamPluginGUI(int w, int h,StreamPlugin *o,ChannelHandler *ch,const HostInfo *Info) :
SpiralPluginGUI(w,h,o,ch),
m_Playing (false),
m_PitchValue (1.0f)
{
// 7 seg displays
@@ -56,7 +57,6 @@ m_PitchValue (1.0f)
m_Pitch->box (FL_PLASTIC_DOWN_BOX);
m_Pitch->maximum (20);
m_Pitch->step (0.001);
UpdatePitch (true, false, false);
m_Pitch->callback ((Fl_Callback*)cb_Pitch);
add (m_Pitch);
// position indicator
@@ -85,17 +85,8 @@ m_PitchValue (1.0f)
m_ToStart->selection_color (Info->GUI_COLOUR);
m_ToStart->callback ((Fl_Callback*)cb_ToStart);
add (m_ToStart);
// stop btn
m_Stop = new Fl_Button (62, 130, 30, 30, "@||");
m_Stop->labelsize (10);
m_Stop->labeltype (FL_SYMBOL_LABEL);
m_Stop->box (FL_PLASTIC_UP_BOX);
m_Stop->color (Info->GUI_COLOUR);
m_Stop->selection_color (Info->GUI_COLOUR);
m_Stop->callback ((Fl_Callback*)cb_Stop);
add (m_Stop);
// play btn
m_Play = new Fl_Button (92, 130, 30, 30, "@>");
m_Play = new Fl_Button (62, 130, 30, 30, "@>");
m_Play->labelsize (10);
m_Play->labeltype (FL_SYMBOL_LABEL);
m_Play->box (FL_PLASTIC_UP_BOX);
@@ -103,22 +94,31 @@ m_PitchValue (1.0f)
m_Play->selection_color (Info->GUI_COLOUR);
m_Play->callback ((Fl_Callback*)cb_Play);
add (m_Play);
// 1/2 speed btn
m_Div = new Fl_Button (122, 130, 30, 30, "/2");
m_Div->labelsize (9);
m_Div->box (FL_PLASTIC_UP_BOX);
m_Div->color (Info->GUI_COLOUR);
m_Div->selection_color (Info->GUI_COLOUR);
m_Div->callback ((Fl_Callback*)cb_Div);
add (m_Div);
// normal speed btn
m_Reset = new Fl_Button (152, 130, 30, 30, "Reset");
m_Reset = new Fl_Button (92, 130, 30, 30, "Reset");
m_Reset->labelsize (9);
m_Reset->box (FL_PLASTIC_UP_BOX);
m_Reset->color (Info->GUI_COLOUR);
m_Reset->selection_color (Info->GUI_COLOUR);
m_Reset->callback ((Fl_Callback*)cb_Reset);
add (m_Reset);
// Reverse Button
m_Rev = new Fl_Button (122, 130, 30, 30, "@<-");
m_Rev->labelsize (10);
m_Rev->labeltype (FL_SYMBOL_LABEL);
m_Rev->box (FL_PLASTIC_UP_BOX);
m_Rev->color (Info->GUI_COLOUR);
m_Rev->selection_color (Info->GUI_COLOUR);
m_Rev->callback ((Fl_Callback*)cb_Rev);
add (m_Rev);
// 1/2 speed btn
m_Div = new Fl_Button (152, 130, 30, 30, "/2");
m_Div->labelsize (9);
m_Div->box (FL_PLASTIC_UP_BOX);
m_Div->color (Info->GUI_COLOUR);
m_Div->selection_color (Info->GUI_COLOUR);
m_Div->callback ((Fl_Callback*)cb_Div);
add (m_Div);
// dbl speed btn
m_Dbl = new Fl_Button (182, 130, 30, 30, "X2");
m_Dbl->labelsize (9);
@@ -135,6 +135,8 @@ m_PitchValue (1.0f)
m_Nudge->selection_color (Info->GUI_COLOUR);
m_Nudge->callback ((Fl_Callback*)cb_Nudge);
add (m_Nudge);
end ();
UpdatePitch (true, false, false);
}

StreamPluginGUI::~StreamPluginGUI () {
@@ -177,8 +179,14 @@ void StreamPluginGUI::cb_Volume (Fl_Knob* o, void* v) {
// pitch

void StreamPluginGUI::UpdatePitch (bool UpdateIt, bool DrawIt, bool SendIt) {
if (m_PitchValue<0) m_Pitch->align (FL_ALIGN_INSIDE | FL_ALIGN_LEFT);
else m_Pitch->align (FL_ALIGN_INSIDE | FL_ALIGN_RIGHT);
if (m_PitchValue<0) {
m_Pitch->align (FL_ALIGN_INSIDE | FL_ALIGN_LEFT);
m_Rev->label ("@->");
}
else {
m_Pitch->align (FL_ALIGN_INSIDE | FL_ALIGN_RIGHT);
m_Rev->label ("@<-");
}
sprintf (m_PitchLabel, " %1.3f ", m_PitchValue);
if (UpdateIt) m_Pitch->value (m_PitchValue+10);
if (DrawIt) redraw();
@@ -232,46 +240,55 @@ void StreamPluginGUI::cb_ToStart (Fl_Button* o, void* v) {
((StreamPluginGUI*)(o->parent ()))->cb_ToStart_i (o, v);
}

// stop
// play

inline void StreamPluginGUI::cb_Stop_i (Fl_Button* o, void* v) {
m_GUICH->SetCommand (StreamPlugin::STOP);
inline void StreamPluginGUI::cb_Play_i (Fl_Button* o, void* v) {
if (m_Playing) {
m_Play->label ("@>");
m_GUICH->SetCommand (StreamPlugin::STOP);
}
else {
m_Play->label ("@||");
m_GUICH->SetCommand (StreamPlugin::PLAY);
}
m_Playing = ! m_Playing;
}

void StreamPluginGUI::cb_Stop (Fl_Button* o, void* v) {
((StreamPluginGUI*)(o->parent ()))->cb_Stop_i (o, v);
void StreamPluginGUI::cb_Play (Fl_Button* o, void* v) {
((StreamPluginGUI*)(o->parent ()))->cb_Play_i (o, v);
}

// play
// reset

inline void StreamPluginGUI::cb_Play_i (Fl_Button* o, void* v) {
m_GUICH->SetCommand (StreamPlugin::PLAY);
inline void StreamPluginGUI::cb_Reset_i (Fl_Button* o, void* v) {
m_PitchValue = 1.0f;
UpdatePitch ();
}

void StreamPluginGUI::cb_Play (Fl_Button* o, void* v) {
((StreamPluginGUI*)(o->parent ()))->cb_Play_i (o, v);
void StreamPluginGUI::cb_Reset (Fl_Button* o, void* v) {
((StreamPluginGUI*)(o->parent ()))->cb_Reset_i (o, v);
}

// div 2
// Rev

inline void StreamPluginGUI::cb_Div_i (Fl_Button* o, void* v) {
m_PitchValue /= 2.0f;
inline void StreamPluginGUI::cb_Rev_i (Fl_Button* o, void* v) {
m_PitchValue = -m_PitchValue;
UpdatePitch ();
}

void StreamPluginGUI::cb_Div (Fl_Button* o, void* v) {
((StreamPluginGUI*)(o->parent()))->cb_Div_i (o, v);
void StreamPluginGUI::cb_Rev (Fl_Button* o, void* v) {
((StreamPluginGUI*)(o->parent ()))->cb_Rev_i (o, v);
}

// reset
// div 2

inline void StreamPluginGUI::cb_Reset_i (Fl_Button* o, void* v) {
m_PitchValue = 1.0f;
inline void StreamPluginGUI::cb_Div_i (Fl_Button* o, void* v) {
m_PitchValue /= 2.0f;
UpdatePitch ();
}

void StreamPluginGUI::cb_Reset (Fl_Button* o, void* v) {
((StreamPluginGUI*)(o->parent ()))->cb_Reset_i (o, v);
void StreamPluginGUI::cb_Div (Fl_Button* o, void* v) {
((StreamPluginGUI*)(o->parent()))->cb_Div_i (o, v);
}

// mul 2


+ 10
- 9
SpiralSound/Plugins/StreamPlugin/StreamPluginGUI.h View File

@@ -16,6 +16,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef StreamGUI
#define StreamGUI

#include <FL/Fl.H>
#include <FL/Fl_Slider.H>
#include <FL/Fl_Repeat_Button.H>
@@ -25,9 +28,6 @@
#include "../Widgets/Fl_SevenSeg.H"
#include "../Widgets/Fl_Knob.H"

#ifndef StreamGUI
#define StreamGUI

class StreamPluginGUI : public SpiralPluginGUI {
public:
StreamPluginGUI(int w, int h, StreamPlugin *o, ChannelHandler *ch, const HostInfo *Info);
@@ -37,6 +37,7 @@ class StreamPluginGUI : public SpiralPluginGUI {
protected:
const string GetHelpText (const string &loc);
private:
bool m_Playing;
float m_PitchValue;
char m_TextBuf[256], m_PitchLabel[256];
void SetMaxTime (float t) { m_Pos->maximum(t); }
@@ -48,10 +49,10 @@ class StreamPluginGUI : public SpiralPluginGUI {
Fl_Slider* m_Pos;
Fl_Button* m_Load;
Fl_Button* m_ToStart;
Fl_Button* m_Stop;
Fl_Button* m_Play;
Fl_Button* m_Div;
Fl_Button* m_Reset;
Fl_Button* m_Rev;
Fl_Button* m_Div;
Fl_Button* m_Dbl;
Fl_Repeat_Button* m_Nudge;
//// Callbacks ////
@@ -65,14 +66,14 @@ class StreamPluginGUI : public SpiralPluginGUI {
static void cb_Load (Fl_Button* o, void* v);
inline void cb_ToStart_i (Fl_Button* o, void* v);
static void cb_ToStart (Fl_Button* o, void* v);
inline void cb_Stop_i (Fl_Button* o, void* v);
static void cb_Stop (Fl_Button* o, void* v);
inline void cb_Play_i (Fl_Button* o, void* v);
static void cb_Play (Fl_Button* o, void* v);
inline void cb_Div_i (Fl_Button* o, void* v);
static void cb_Div (Fl_Button* o, void* v);
inline void cb_Reset_i (Fl_Button* o, void* v);
static void cb_Reset (Fl_Button* o, void* v);
inline void cb_Rev_i (Fl_Button* o, void* v);
static void cb_Rev (Fl_Button* o, void* v);
inline void cb_Div_i (Fl_Button* o, void* v);
static void cb_Div (Fl_Button* o, void* v);
inline void cb_Dbl_i (Fl_Button* o, void* v);
static void cb_Dbl (Fl_Button* o, void* v);
inline void cb_Nudge_i (Fl_Button* o, void* v);


Loading…
Cancel
Save