Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updates to recording

  • Loading branch information...
commit 91fd3cc6c3dff3885ad93b1afbfac1b3aeac65ca 1 parent bc105ec
Josh Siegle authored
View
10 Source/Processors/Channel.cpp
@@ -30,6 +30,7 @@ Channel::Channel(GenericProcessor* p, int n) :
sampleRate(44100.0f), bitVolts(1.0f), eventType(0)
{
+ nodeId = p->getNodeId();
createDefaultName();
}
@@ -45,9 +46,16 @@ Channel::Channel(const Channel& ch)
bitVolts = ch.bitVolts;
name = ch.name;
eventType = ch.eventType;
+ nodeId = ch.nodeId;
}
+void Channel::setProcessor(GenericProcessor* p)
+{
+ processor = p;
+ nodeId = p->getNodeId();
+}
+
String Channel::getName()
{
return name;
@@ -66,5 +74,5 @@ void Channel::reset()
void Channel::createDefaultName()
{
name = String("CH");
- name += num;
+ name += (num + 1);
}
View
5 Source/Processors/Channel.h
@@ -60,9 +60,14 @@ class Channel
void reset();
+ void setProcessor(GenericProcessor*);
+
// channel number:
int num;
+ // node id
+ int nodeId;
+
// event info:
int eventType;
View
1  Source/Processors/GenericProcessor.cpp
@@ -306,6 +306,7 @@ void GenericProcessor::update()
{
Channel* sourceChan = sourceNode->channels[i];
Channel* ch = new Channel(*sourceChan);
+ ch->setProcessor(this);
channels.add(ch);
}
View
4 Source/Processors/PhaseDetector.cpp
@@ -88,10 +88,10 @@ void PhaseDetector::handleEvent(int eventType, MidiMessage& event, int sampleNum
// std::cout << "Received event from " << eventNodeId << ", channel "
// << eventChannel << ", with ID " << eventId << std::endl;
- if (eventId == 1)
+ if (eventId == 1 && eventChannel == 5)
{
canBeTriggered = true;
- } else {
+ } else if (eventId == 0 && eventChannel == 5) {
canBeTriggered = false;
}
View
59 Source/Processors/RecordNode.cpp
@@ -42,6 +42,13 @@ RecordNode::RecordNode()
eventChannel = new Channel(this, 0);
eventChannel->isEventChannel = true;
+ recordMarker = new char[10];
+ for (int i = 0; i < 9; i++)
+ {
+ recordMarker[i] = 0;
+ }
+ recordMarker[9] = 255;
+
// 128 inputs, 0 outputs
setPlayConfigDetails(getNumInputs(),getNumOutputs(),44100.0,128);
@@ -136,6 +143,8 @@ void RecordNode::addInputChannel(GenericProcessor* sourceNode, int chan)
channelPointers.add(sourceNode->channels[chan]);
+ // std::cout << channelIndex << std::endl;
+
updateFileName(channelPointers[channelIndex]);
@@ -174,7 +183,7 @@ void RecordNode::updateFileName(Channel* ch)
if (!ch->isEventChannel)
{
- filename += ch->processor->getNodeId();
+ filename += ch->nodeId;
filename += "_";
filename += ch->name;
filename += ".continuous";
@@ -185,6 +194,8 @@ void RecordNode::updateFileName(Channel* ch)
ch->filename = filename;
ch->file = 0;
+ //std::cout << "Updating " << filename << std::endl;
+
}
void RecordNode::createNewDirectory()
@@ -445,27 +456,41 @@ void RecordNode::writeContinuousBuffer(float* data, int nSamples, int channel)
// find file and write samples to disk
- AudioDataConverters::convertFloatToInt16BE(continuousDataFloatBuffer, continuousDataIntegerBuffer, nSamples);
+ //if (nSamples < 1000) // this is temporary, but there seems to be an error reading in the data if too many samples are written
+ // in the first few blocks
+ //{
- int16 samps = (int16) nSamples;
+ AudioDataConverters::convertFloatToInt16BE(continuousDataFloatBuffer, continuousDataIntegerBuffer, nSamples);
- //std::cout << samps << std::endl;
+ int16 samps = (int16) nSamples;
+
+ //std::cout << samps << std::endl;
+
+ fwrite(&timestamp, // ptr
+ 8, // size of each element
+ 1, // count
+ channelPointers[channel]->file); // ptr to FILE object
+
+ fwrite(&samps, // ptr
+ 2, // size of each element
+ 1, // count
+ channelPointers[channel]->file); // ptr to FILE object
+
+ int n = fwrite(continuousDataIntegerBuffer, // ptr
+ 2, // size of each element
+ nSamples, // count
+ channelPointers[channel]->file); // ptr to FILE object
+ // n must equal "count", otherwise there was an error
+
+ // write a 10-byte marker indicating the end of a record
+ fwrite(recordMarker, // ptr
+ 1, // size of each element
+ 10, // count
+ channelPointers[channel]->file); // ptr to FILE object
- fwrite(&timestamp, // ptr
- 8, // size of each element
- 1, // count
- channelPointers[channel]->file); // ptr to FILE object
- fwrite(&samps, // ptr
- 2, // size of each element
- 1, // count
- channelPointers[channel]->file); // ptr to FILE object
- int n = fwrite(continuousDataIntegerBuffer, // ptr
- 2, // size of each element
- nSamples, // count
- channelPointers[channel]->file); // ptr to FILE object
- // n must equal "count", otherwise there was an error
+ //}
}
void RecordNode::writeEventBuffer(MidiMessage& event, int samplePosition) //, int node, int channel)
View
3  Source/Processors/RecordNode.h
@@ -179,6 +179,9 @@ class RecordNode : public GenericProcessor,
*/
void writeEventBuffer(MidiMessage& event, int samplePos);
+ /** Used to indicate the end of each record */
+ char* recordMarker;
+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RecordNode);
};
View
4 Source/Processors/SourceNode.cpp
@@ -307,8 +307,8 @@ void SourceNode::process(AudioSampleBuffer &buffer,
);
} else {
- std::cout << "ON" << std::endl;
- std::cout << c << std::endl;
+ // std::cout << "ON" << std::endl;
+ // std::cout << c << std::endl;
// signal channel state is ON
addEvent(events, // MidiBuffer
Please sign in to comment.
Something went wrong with that request. Please try again.