Skip to content
Snippets Groups Projects
Commit 634bc4a6 authored by Ryan Maloney's avatar Ryan Maloney
Browse files

Merge pull request #1 from open-ephys/master

Catch Up
parents 8c729319 aa4d029f
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ This repository contains all of the files (save for a few dependencies) you'll n
We recommend reading through the GitHub wiki_ before attempting to make any changes.
If you want to add files, you'll have to do that through "The Jucer," using the "open-ephys.jucer" file. The Jucer makefiles are located in the JuceLibraryCode/jucer/Builds folder, or as part of the Juce library package on SourceForge_.
If you want to add files, you'll have to do that through the "Introjucer," using the "open-ephys.jucer" file. The Introjucer makefiles are located in the JuceLibraryCode/Introjucer/Builds folder, or as part of the Juce library package on SourceForge_.
.. _SourceForge: http://sourceforge.net/projects/juce/files/juce/
.. _JUCE: http://www.rawmaterialsoftware.com/juce.php
......
......@@ -26,7 +26,7 @@
DataBuffer::DataBuffer(int chans, int size)
: abstractFifo(size), buffer(chans, size), numChans(chans)
{
timestampBuffer = new uint64[size];
timestampBuffer = new uint64_t[size];
eventCodeBuffer = new int16[size];
}
......@@ -42,13 +42,13 @@ void DataBuffer::clear()
void DataBuffer::resize(int chans, int size)
{
buffer.setSize(chans, size);
timestampBuffer = new uint64[size];
timestampBuffer = new uint64_t[size];
eventCodeBuffer = new int16[size];
numChans = chans;
}
void DataBuffer::addToBuffer(float* data, uint64* timestamps, int16* eventCodes, int numItems)
void DataBuffer::addToBuffer(float* data, uint64_t* timestamps, int16* eventCodes, int numItems)
{
// writes one sample for all channels
int startIndex1, blockSize1, startIndex2, blockSize2;
......@@ -75,7 +75,7 @@ int DataBuffer::getNumSamples()
}
int DataBuffer::readAllFromBuffer(AudioSampleBuffer& data, uint64* timestamp, int16* eventCodes, int maxSize)
int DataBuffer::readAllFromBuffer(AudioSampleBuffer& data, uint64_t* timestamp, int16* eventCodes, int maxSize)
{
// check to see if the maximum size is smaller than the total number of available ints
int numItems = (maxSize < abstractFifo.getNumReady()) ?
......
......@@ -45,13 +45,13 @@ public:
void clear();
/** Add an array of floats to the buffer.*/
void addToBuffer(float* data, uint64* ts, int16* eventCodes, int numItems);
void addToBuffer(float* data, uint64_t* ts, int16* eventCodes, int numItems);
/** Returns the number of samples currently available in the buffer.*/
int getNumSamples();
/** Copies as many samples as possible from the DataBuffer to an AudioSampleBuffer.*/
int readAllFromBuffer(AudioSampleBuffer& data, uint64* ts, int16* eventCodes, int maxSize);
int readAllFromBuffer(AudioSampleBuffer& data, uint64_t* ts, int16* eventCodes, int maxSize);
/** Resizes the data buffer */
void resize(int chans, int size);
......@@ -60,7 +60,7 @@ private:
AbstractFifo abstractFifo;
AudioSampleBuffer buffer;
uint64* timestampBuffer;
uint64_t* timestampBuffer;
int16* eventCodeBuffer;
int numChans;
......
......@@ -29,6 +29,11 @@ DataThread::DataThread(SourceNode* s) : Thread("Data Thread"), dataBuffer(0)
{
sn = s;
setPriority(10);
timestamp = 0; // set default to zero, so that sources that
// do not generate their own timestamps can simply increment
// this value
}
DataThread::~DataThread()
......
......@@ -96,7 +96,7 @@ public:
SourceNode* sn;
int16 eventCode;
uint64 timestamp;
uint64_t timestamp;
Time timer;
......
......@@ -137,11 +137,15 @@ bool FileReaderThread::updateBuffer()
for (int n = 0; n < bufferSize; n++)
{
thisSample[chan] = float(-readBuffer[n])*0.035;
thisSample[chan] = float(-readBuffer[n])*0.035; // previously 0.035
if (chan == 15)
{
timestamp = timer.getHighResolutionTicks();
timestamp++; // = (0 << 0) + (0 << 8) + (0 << 16) + (0 << 24); // +
//(4 << 32); // + (3 << 40) + (2 << 48) + (1 << 56);
//timestamp++; // = timer.getHighResolutionTicks();
dataBuffer->addToBuffer(thisSample, &timestamp, &eventCode, 1);
chan = 0;
}
......
......@@ -469,7 +469,7 @@ void GenericProcessor::addEvent(MidiBuffer& eventBuffer,
data[1] = nodeId; // processor ID automatically added
data[2] = eventId; // event ID
data[3] = eventChannel; // event channel
memcpy(&data[4], eventData, numBytes);
memcpy(data + 4, eventData, numBytes);
eventBuffer.addEvent(data, // spike data
sizeof(data), // total bytes
......@@ -478,7 +478,6 @@ void GenericProcessor::addEvent(MidiBuffer& eventBuffer,
//if (type == TTL)
// std::cout << "Adding event for channel " << (int) eventChannel << " with ID " << (int) eventId << std::endl;
delete data;
}
// void GenericProcessor::unpackEvent(int type,
......
......@@ -531,6 +531,8 @@ void RecordNode::writeContinuousBuffer(float* data, int nSamples, int channel)
//std::cout << samps << std::endl;
// std::cout << "Record node timestamp: " << timestamp << std::endl;
fwrite(&timestamp, // ptr
8, // size of each element
1, // count
......@@ -565,10 +567,12 @@ void RecordNode::writeEventBuffer(MidiMessage& event, int samplePosition) //, in
//std::cout << "Received event!" << std::endl;
const uint8* dataptr = event.getRawData();
int16 samplePos = (int16) samplePosition;
uint64_t samplePos = (uint64_t) samplePosition;
uint64_t eventTimestamp = timestamp + samplePos;
// write timestamp (for buffer only, not the actual event timestamp!!!!!)
fwrite(&timestamp, // ptr
fwrite(&eventTimestamp, // ptr
8, // size of each element
1, // count
eventChannel->file); // ptr to FILE object
......@@ -592,7 +596,26 @@ void RecordNode::handleEvent(int eventType, MidiMessage& event, int samplePositi
else if (eventType == TIMESTAMP)
{
const uint8* dataptr = event.getRawData();
memcpy(&timestamp, dataptr, 8);
// std::cout << (int) *(dataptr + 11) << " " <<
// (int) *(dataptr + 10) << " " <<
// (int) *(dataptr + 9) << " " <<
// (int) *(dataptr + 8) << " " <<
// (int) *(dataptr + 7) << " " <<
// (int) *(dataptr + 6) << " " <<
// (int) *(dataptr + 5) << " " <<
// (int) *(dataptr + 4) << std::endl;
// timestamp = ((uint64) *(dataptr + 4)) +
// ((uint64) *(dataptr + 5)) << 8;
// ((uint64) *(dataptr + 6)) << 16;
// ((uint64) *(dataptr + 7)) << 24;
// ((uint64) *(dataptr + 8)) << 32 +
// ((uint64) *(dataptr + 9)) << 40 +
// ((uint64) *(dataptr + 10)) << 48 +
// ((uint64) *(dataptr + 11)) << 56;
memcpy(&timestamp, dataptr + 4, 4); // remember to skip first four bytes
}
}
......
......@@ -131,7 +131,7 @@ private:
/** Integer timestamp saved for each buffer.
*/
uint64 timestamp;
uint64_t timestamp;
/** Used to generate timestamps if none are given.
*/
......
......@@ -325,7 +325,7 @@ void SourceNode::process(AudioSampleBuffer& buffer,
nSamples = inputBuffer->readAllFromBuffer(buffer, &timestamp, eventCodeBuffer, buffer.getNumSamples());
//std::cout << "TIMESTAMP: " << timestamp << std::endl;
//std::cout << "Source node timestamp: " << timestamp << std::endl;
//std::cout << "Samples per buffer: " << nSamples << std::endl;
......@@ -342,6 +342,16 @@ void SourceNode::process(AudioSampleBuffer& buffer,
data // data
);
// std::cout << (int) *(data + 7) << " " <<
// (int) *(data + 6) << " " <<
// (int) *(data + 5) << " " <<
// (int) *(data + 4) << " " <<
// (int) *(data + 3) << " " <<
// (int) *(data + 2) << " " <<
// (int) *(data + 1) << " " <<
// (int) *(data + 0) << std::endl;
// fill event buffer
for (int i = 0; i < nSamples; i++)
{
......
......@@ -103,7 +103,7 @@ private:
ScopedPointer<DataThread> dataThread;
DataBuffer* inputBuffer;
uint64 timestamp;
uint64_t timestamp;
int16* eventCodeBuffer;
int* eventChannelState;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment