CSL  6.0
CSL_AbstComponent.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This is an automatically generated file created by the Jucer!
5 
6  Creation date: 17 Sep 2009 3:29:44 pm
7 
8  Be careful when adding custom code to these files, as only the code within
9  the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
10  and re-saved.
11 
12  Jucer version: 1.12
13 
14  ------------------------------------------------------------------------------
15 
16  The Jucer is part of the JUCE library - "Jules' Utility Class Extensions"
17  Copyright 2004-6 by Raw Material Software ltd.
18 
19  ==============================================================================
20 */
21 
22 #ifndef __JUCER_HEADER_CSLABCOMPONENT_CSLTESTCOMPONENT_AC44DB4F__
23 #define __JUCER_HEADER_CSLABCOMPONENT_CSLTESTCOMPONENT_AC44DB4F__
24 
25 //[Headers] -- You can add your own extra header files here --
26 
27 /// This is the CSL_AbstComponent JUCE wrapper for the CSL demos
28 ///
29 /// See the copyright notice and acknowledgment of authors in the file COPYRIGHT
30 ///
31 /// It loads a set of test code files for CSL tests and displays a menu of the tests.
32 ///
33 /// USAGE: CSL_Juce [suite#] [test#]
34 ///
35 /// The main() function reads argv[1] as the suite selector (from the above list, 1-based)
36 /// and argv[2] as the test within the suite, e.g., use "2 10" to select the 10th test in the
37 /// srcTestList suite ("Vector IFFT" -- found at the bottom of Test_Sources.cpp).
38 /// This is useful for debugging; set up the GUI to run the test you're working on.
39 ///
40 /// The demo also writes the last used test to ~/.cslrc so that it starts up with the same demo.
41 ///
42 
43 #include "CSL_Includes.h" // CSL core
44 #include "JuceHeader.h"
45 #include "JCSL_Widgets.h" // my custom widgets (VU meter and oscilloscope)
46 
47 // Support code: CSL player thread
48 
49 // a thread class that takes a function
50 
51 typedef void* (*ThreadFunc)(void*); // Thread function signature
52 
53 // Support classes
54 
55 /// GThread takes a CSL test function and runs it
56 
57 class GThread : public juce::Thread {
58 public:
59  GThread(ThreadFunc afcn) : Thread("CSL Thread"), fcn(afcn) { };
60  void * (*fcn)(void *);
61 
62  void run() {
63  (*fcn)(NULL); // call my function
64  csl::sleepMsec(100); // wait a bit for it to stop
65  };
66 };
67 
68 /// LThread loops a CThread
69 
70 class CSLAbstComponent; // forward decl
71 
72 class LThread : public juce::Thread {
73 public:
74  LThread(GThread * athr, CSLAbstComponent * acomp, bool looper)
75  : Thread("CSL Thread"),
76  thr(athr), comp(acomp), loop(looper) { };
77  GThread * thr;
79  bool loop;
80 
81  void run();
82 };
83 
84 //[/Headers]
85 
86 //==============================================================================
87 /**
88  //[Comments]
89  CSLAbstComponent
90  //[/Comments]
91 */
92 class CSLAbstComponent : public juce::Component,
93  public juce::AudioIODeviceCallback,
94  public juce::Timer {
95 public:
98 
99  //[UserMethods] -- You can add your own custom methods in this section.
100 
101  virtual void audioDeviceIOCallback (const float** inputChannelData,
102  int totalNumInputChannels,
103  float** outputChannelData,
104  int totalNumOutputChannels,
105  int numSamples);
106  virtual void audioDeviceAboutToStart (juce::AudioIODevice* device);
107  virtual void audioDeviceStopped();
108 
109  virtual void recordOnOff();
110  virtual void startStop(csl::VoidFcnPtrN * fcn);
111 
112  virtual void timerCallback();
113 
114  //[/UserMethods]
115 
116  juce_UseDebuggingNewOperator
117 
118 //private:
119  //[UserVariables] -- You can add your own custom variables in this section.
120 
121  juce::AudioDeviceManager mAudioDeviceManager; // JUCE audio
122  csl::Buffer outBuffer; // main CSL buffer
123  GThread * playThread; // test play and looper threads
125  float amplValue; // amp scale
126  bool loop, recrding, playing, displayMode, changed; // state flags
127 
128  //[/UserVariables]
129 
130  // (prevent copy constructor and operator= being generated..)
133 };
134 
135 // Signal component has the widgets of the JUCE demo
136 
138  public juce::Button::Listener,
139  public juce::ComboBox::Listener,
140  public juce::Slider::Listener {
141 public:
144 
145  virtual void resized();
146  virtual void buttonClicked (juce::Button* buttonThatWasClicked);
147  virtual void comboBoxChanged (juce::ComboBox* comboBoxThatHasChanged);
148  virtual void sliderValueChanged (juce::Slider* sliderThatWasMoved);
149 
150  virtual void audioDeviceIOCallback (const float** inputChannelData,
151  int totalNumInputChannels,
152  float** outputChannelData,
153  int totalNumOutputChannels,
154  int numSamples);
155 
156  juce::TextButton* playButton; ///< Buttons, sliders and meters
157  juce::TextButton* quitButton;
158  juce::TextButton* prefsButton;
159  juce::Label* cpuLabel;
162  juce::Slider* amplitudeSlider;
163  juce::ToggleButton* loopButton;
164  juce::ToggleButton* recordButton;
165 };
166 
167 #endif // __JUCER_HEADER_CSLCOMPONENT_CSLTESTCOMPONENT_AC44DB4F__
juce::TextButton * quitButton
void *(* ThreadFunc)(void *)
This is the CSL_AbstComponent JUCE wrapper for the CSL demos.
juce::ToggleButton * loopButton
bool sleepMsec(float dur)
Definition: CGestalt.cpp:372
virtual void comboBoxChanged(juce::ComboBox *comboBoxThatHasChanged)
GThread * thr
virtual void audioDeviceIOCallback(const float **inputChannelData, int totalNumInputChannels, float **outputChannelData, int totalNumOutputChannels, int numSamples)
GThread takes a CSL test function and runs it.
void *(* fcn)(void *)
const CSLAbstComponent & operator=(const CSLAbstComponent &)
juce::Label * cpuLabel
juce_UseDebuggingNewOperator juce::AudioDeviceManager mAudioDeviceManager
void VoidFcnPtrN(void)
the truly void fcn pointer
Definition: CSL_Types.h:222
GThread(ThreadFunc afcn)
virtual void buttonClicked(juce::Button *buttonThatWasClicked)
virtual void audioDeviceStopped()
virtual void sliderValueChanged(juce::Slider *sliderThatWasMoved)
virtual void audioDeviceAboutToStart(juce::AudioIODevice *device)
LThread(GThread *athr, CSLAbstComponent *acomp, bool looper)
juce::Slider * amplitudeSlider
juce::ToggleButton * recordButton
virtual void timerCallback()
juce::TextButton * prefsButton
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
Definition: CSL_Core.h:106
virtual void audioDeviceIOCallback(const float **inputChannelData, int totalNumInputChannels, float **outputChannelData, int totalNumOutputChannels, int numSamples)
juce::TextButton * playButton
Buttons, sliders and meters.
virtual void startStop(csl::VoidFcnPtrN *fcn)
CSLAbstComponent * comp
virtual void recordOnOff()