Open Ephys GUI
 All Classes Functions Variables Pages
SourceNode.h
1 /*
2  ------------------------------------------------------------------
3 
4  This file is part of the Open Ephys GUI
5  Copyright (C) 2012 Open Ephys
6 
7  ------------------------------------------------------------------
8 
9  This program is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program. If not, see <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifndef __SOURCENODE_H_DCE798F1__
25 #define __SOURCENODE_H_DCE798F1__
26 
27 #include "../../JuceLibraryCode/JuceHeader.h"
28 #include <ftdi.h>
29 #include <stdio.h>
30 #include "DataThreads/DataBuffer.h"
31 #include "DataThreads/IntanThread.h"
32 #include "DataThreads/FPGAThread.h"
33 #include "DataThreads/FileReaderThread.h"
34 #include "GenericProcessor.h"
35 #include "../UI/UIComponent.h"
36 
37 /**
38 
39  Creates and controls a thread for reading data from external sources.
40 
41  @see GenericProcessor, SourceNodeEditor, DataThread, IntanThread
42 
43 */
44 
46  public Timer
47 
48 {
49 public:
50 
51  // real member functions:
52  SourceNode(const String& name);
53  ~SourceNode();
54 
55  void enabledState(bool t);
56 
57  void process(AudioSampleBuffer &buffer, MidiBuffer &midiMessages, int& nSamples);
58 
59  void setParameter (int parameterIndex, float newValue);
60 
61  float getSampleRate();
62  float getDefaultSampleRate();
63  int getDefaultNumOutputs();
64  float getDefaultBitVolts();
65 
66  AudioProcessorEditor* createEditor();
67  bool hasEditor() const {return true;}
68 
69  bool enable();
70  bool disable();
71 
72  bool isReady();
73 
74  bool isSource() {return true;}
75 
76  void acquisitionStopped();
77 
78 private:
79 
80  int sourceCheckInterval;
81 
82  bool wasDisabled;
83 
84  void timerCallback();
85 
86  ScopedPointer<DataThread> dataThread;
87  DataBuffer* inputBuffer;
88 
89  void updateSettings();
90 
91  int* numSamplesInThisBuffer;
92 
93  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SourceNode);
94 
95 };
96 
97 
98 #endif // __SOURCENODE_H_DCE798F1__
99