Open Ephys GUI
 All Classes Functions Variables
RecordNode.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 __RECORDNODE_H_FB9B1CA7__
25 #define __RECORDNODE_H_FB9B1CA7__
26 
27 
28 #include "../../JuceLibraryCode/JuceHeader.h"
29 #include <stdio.h>
30 #include <map>
31 
32 #include "GenericProcessor.h"
33 
46  public FilenameComponentListener
47 {
48 public:
49 
50  RecordNode();
51  ~RecordNode();
52 
53  void process(AudioSampleBuffer &buffer, MidiBuffer &eventBuffer, int& nSamples);
54 
55  void setParameter (int parameterIndex, float newValue);
56 
57  void addInputChannel(GenericProcessor* sourceNode, int chan);
58 
59  bool enable();
60  bool disable();
61 
65  float getFreeSpace();
66 
67  void setChannel(int id, int chan);
68 
69  void setChannelStatus(int chan, bool status);
70 
71  void resetConnections();
72 
73  bool isAudioOrRecordNode() {return true;}
74 
75  void filenameComponentChanged(FilenameComponent*);
76 
77  void createNewDirectory();
78 
79 private:
80 
83  bool isRecording, isProcessing, signalFilesShouldClose;
84 
89 
92  File rootFolder;
93 
98 
103 
106  int64 timestamp;
107 
110  Time timer;
111 
115  struct Channel
116  {
117  int nodeId;
118  int chan;
119  String name;
120  bool isRecording;
121  String filename;
122  FILE* file;
123  };
124 
125  void closeAllFiles();
126 
129  std::map<int, Channel> continuousChannels;
130 
133  std::map<int, std::map<int,Channel> > eventChannels;
134 
137  void writeContinuousBuffer(float* data, int nSamples, int channel);
138 
141  void writeEventBuffer(MidiMessage& event, int node, int channel);
142 
143  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RecordNode);
144 
145 };
146 
147 
148 
149 #endif // __RECORDNODE_H_FB9B1CA7__