FieldTripBufferSource : 64-bit floats data format
Posted: 11 May 2015, 08:11
Hi everybody,
I would like to be able to read 64-bit floats data format from the buffer of FieldTripBufferSource.
I noticed that currently, the only supported data formats that can be grabbed from the buffer are 16-bit integers, 32-bit integers, and 32-bit floats.
However, I wonder if someone is developping or has already developped this functionnality ?
Otherwise, is there possible to help me to integrate it? I have already done some modifications but I am in difficulty to do some changes in some files...
Thank you very much for your help
This is the changes I did :
FieldTripBufferADC.cpp
…
{
SignalType::Type sType;
switch(hdr.data_type) {
case DATATYPE_INT32:
sType = SignalType::int32;
break;
case DATATYPE_INT16:
sType = SignalType::int16;
break;
case DATATYPE_FLOAT32:
sType = SignalType::float32;
break;
case DATATYPE_FLOAT64:
sType = SignalType::float64;
break;
default:
bcierr << "Datatype : '" << hdr.data_type << "' not supported yet" << endl;
return;
}
…
switch(datadef.data_type) {
case DATATYPE_INT16:
{
INT16_T *src = (INT16_T *) databuf.data();
for( int sample = 0; sample < Output.Elements(); ++sample )
for( int channel = 0; channel < Output.Channels(); ++channel )
Output( channel, sample ) = *src++;
}
break;
case DATATYPE_INT32:
{
INT32_T *src = (INT32_T *) databuf.data();
for( int sample = 0; sample < Output.Elements(); ++sample )
for( int channel = 0; channel < Output.Channels(); ++channel )
Output( channel, sample ) = *src++;
}
break;
case DATATYPE_FLOAT32:
{
FLOAT32_T *src = (FLOAT32_T *) databuf.data();
for( int sample = 0; sample < Output.Elements(); ++sample )
for( int channel = 0; channel < Output.Channels(); ++channel )
Output( channel, sample ) = *src++;
}
break;
case DATATYPE_FLOAT64:
{
FLOAT64_T *src = (FLOAT64_T *) databuf.data();
for( int sample = 0; sample < Output.Elements(); ++sample )
for( int channel = 0; channel < Output.Channels(); ++channel )
Output( channel, sample ) = *src++;
}
break;
}
____________________________________________________________________________
SignalType.h
…
typedef enum Type
{
none = -1,
int16 = 0,
float24,
float32,
int32,
float64,
numTypes,
defaultType = float32
} Type;
…
____________________________________________________________________________
SignalType.cpp
…
SignalTypeProperties[] =
{
{ SignalType::int16, "int16", 2, - ( 1 << 15 ), ( 1 << 15 ) - 1 },
{ SignalType::float24, "float24", 3, - numeric_limits<float>::max(), numeric_limits<float>::max() },
{ SignalType::float32, "float32", 4, - numeric_limits<float>::max(), numeric_limits<float>::max() },
{ SignalType::float64, "float64", ?, - numeric_limits<double>::max(), numeric_limits<double>::max() },
#if defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0560 ) // bcc32 5.5.1 does not have LL type
{ SignalType::int32, "int32", 4, - ( 1i64 << 31 ), ( 1i64 << 31 ) - 1 },
#else // __BORLANDC__
{ SignalType::int32, "int32", 4, - ( 1LL << 31 ), ( 1LL << 31 ) - 1 },
#endif // __BORLANDC__
};
…
static const bool conversionTable[ numTypes ][ numTypes ] =
{
/* int16 float24 float32 int32 float64*/
/* int16 */ { true, true, true, true, ? },
/* float24 */ { false, true, true, false, ? },
/* float32 */ { false, false, true, false, ? },
/* int32 */ { false, false, false, true, ? },
/* float64 */ { ? , ? , ? , ? , ? },
};
…
____________________________________________________________________________
BCI2000OutputFormat.cpp
…
switch( inProperties.Type() )
{
case SignalType::int16:
case SignalType::int32:
case SignalType::float32:
case SignalType::float64:
/* These types are OK */
break;
default:
bcierr << inProperties.Type().Name()
<< " data type unsupported for BCI2000 files"
<< endl;
}
…
BCI2000OutputFormat::Write( ostream& os, const GenericSignal& inSignal, const StateVector& inStatevector )
{
switch( mInputProperties.Type() )
{
case SignalType::int16:
PutBlock<SignalType::int16>( os, inSignal, inStatevector );
break;
case SignalType::float32:
PutBlock<SignalType::float32>( os, inSignal, inStatevector );
break;
case SignalType::int32:
PutBlock<SignalType::int32>( os, inSignal, inStatevector );
break;
case SignalType::float64:
PutBlock<SignalType::float64>( os, inSignal, inStatevector );
break;
default:
bcierr << "Unsupported signal data type" << endl;
}
}
…
____________________________________________________________________________
BCI2000FileReader.cpp
…
if( isBigEndian )
{
switch( mSignalType )
{
case SignalType::int16:
value = ReadValue_SwapBytes<int16_t>( address );
break;
case SignalType::int32:
value = ReadValue_SwapBytes<int32_t>( address );
break;
case SignalType::float32:
value = ReadValue_SwapBytes<float32_t>( address );
break;
case SignalType::float64:
value = ReadValue_SwapBytes<float64_t>( address );
break;
default:
break;
}
}
else
{ // Little endian machine
switch( mSignalType )
{
case SignalType::int16:
value = ReadValue<int16_t>( address );
break;
case SignalType::int32:
value = ReadValue<int32_t>( address );
break;
case SignalType::float32:
value = ReadValue<float32_t>( address );
break;
case SignalType::float64:
value = ReadValue<float64_t>( address );
break;
default:
break;
}
}
…
____________________________________________________________________________
defines.h
…
typedef float float32_t;
typedef double float64_t;
// Backward compatibility (for new code, use stdint types):
#if 1
typedef uint8_t uint8;
typedef int8_t sint8;
typedef uint16_t uint16;
typedef int16_t sint16;
typedef uint32_t uint32;
typedef int32_t sint32;
typedef uint64_t uint64;
typedef int64_t sint64;
typedef float32_t float32;
typedef float64_t float64;
#endif
…
____________________________________________________________________________
message.h
Do we have to do changes in this file?
____________________________________________________________________________
topsocket.c
Do we have to do changes in this file?
____________________________________________________________________________
swapbytes.c
Do we have to do changes in this file?
____________________________________________________________________________
swapbytes.h
Do we have to do changes in this file?
____________________________________________________________________________
GenericSignal.h
…
template<> void
GenericSignal::PutValueBinary<SignalType::int16>( std::ostream&, size_t, size_t ) const;
template<> void
GenericSignal::PutValueBinary<SignalType::int32>( std::ostream&, size_t, size_t ) const;
template<> void
GenericSignal::PutValueBinary<SignalType::float24>( std::ostream&, size_t, size_t ) const;
template<> void
GenericSignal::PutValueBinary<SignalType::float32>( std::ostream&, size_t, size_t ) const;
template<> void
GenericSignal::PutValueBinary<SignalType::float64>( std::ostream&, size_t, size_t ) const;
template<> void
GenericSignal::GetValueBinary<SignalType::int16>( std::istream&, size_t, size_t );
template<> void
GenericSignal::GetValueBinary<SignalType::int32>( std::istream&, size_t, size_t );
template<> void
GenericSignal::GetValueBinary<SignalType::float24>( std::istream&, size_t, size_t );
template<> void
GenericSignal::GetValueBinary<SignalType::float32>( std::istream&, size_t, size_t );
template<> void
GenericSignal::GetValueBinary<SignalType::float64>( std::istream&, size_t, size_t );
…
____________________________________________________________________________
GenericSignal.cpp
I don’t know what it should be modified.
I would like to be able to read 64-bit floats data format from the buffer of FieldTripBufferSource.
I noticed that currently, the only supported data formats that can be grabbed from the buffer are 16-bit integers, 32-bit integers, and 32-bit floats.
However, I wonder if someone is developping or has already developped this functionnality ?
Otherwise, is there possible to help me to integrate it? I have already done some modifications but I am in difficulty to do some changes in some files...
Thank you very much for your help
This is the changes I did :
FieldTripBufferADC.cpp
…
{
SignalType::Type sType;
switch(hdr.data_type) {
case DATATYPE_INT32:
sType = SignalType::int32;
break;
case DATATYPE_INT16:
sType = SignalType::int16;
break;
case DATATYPE_FLOAT32:
sType = SignalType::float32;
break;
case DATATYPE_FLOAT64:
sType = SignalType::float64;
break;
default:
bcierr << "Datatype : '" << hdr.data_type << "' not supported yet" << endl;
return;
}
…
switch(datadef.data_type) {
case DATATYPE_INT16:
{
INT16_T *src = (INT16_T *) databuf.data();
for( int sample = 0; sample < Output.Elements(); ++sample )
for( int channel = 0; channel < Output.Channels(); ++channel )
Output( channel, sample ) = *src++;
}
break;
case DATATYPE_INT32:
{
INT32_T *src = (INT32_T *) databuf.data();
for( int sample = 0; sample < Output.Elements(); ++sample )
for( int channel = 0; channel < Output.Channels(); ++channel )
Output( channel, sample ) = *src++;
}
break;
case DATATYPE_FLOAT32:
{
FLOAT32_T *src = (FLOAT32_T *) databuf.data();
for( int sample = 0; sample < Output.Elements(); ++sample )
for( int channel = 0; channel < Output.Channels(); ++channel )
Output( channel, sample ) = *src++;
}
break;
case DATATYPE_FLOAT64:
{
FLOAT64_T *src = (FLOAT64_T *) databuf.data();
for( int sample = 0; sample < Output.Elements(); ++sample )
for( int channel = 0; channel < Output.Channels(); ++channel )
Output( channel, sample ) = *src++;
}
break;
}
____________________________________________________________________________
SignalType.h
…
typedef enum Type
{
none = -1,
int16 = 0,
float24,
float32,
int32,
float64,
numTypes,
defaultType = float32
} Type;
…
____________________________________________________________________________
SignalType.cpp
…
SignalTypeProperties[] =
{
{ SignalType::int16, "int16", 2, - ( 1 << 15 ), ( 1 << 15 ) - 1 },
{ SignalType::float24, "float24", 3, - numeric_limits<float>::max(), numeric_limits<float>::max() },
{ SignalType::float32, "float32", 4, - numeric_limits<float>::max(), numeric_limits<float>::max() },
{ SignalType::float64, "float64", ?, - numeric_limits<double>::max(), numeric_limits<double>::max() },
#if defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0560 ) // bcc32 5.5.1 does not have LL type
{ SignalType::int32, "int32", 4, - ( 1i64 << 31 ), ( 1i64 << 31 ) - 1 },
#else // __BORLANDC__
{ SignalType::int32, "int32", 4, - ( 1LL << 31 ), ( 1LL << 31 ) - 1 },
#endif // __BORLANDC__
};
…
static const bool conversionTable[ numTypes ][ numTypes ] =
{
/* int16 float24 float32 int32 float64*/
/* int16 */ { true, true, true, true, ? },
/* float24 */ { false, true, true, false, ? },
/* float32 */ { false, false, true, false, ? },
/* int32 */ { false, false, false, true, ? },
/* float64 */ { ? , ? , ? , ? , ? },
};
…
____________________________________________________________________________
BCI2000OutputFormat.cpp
…
switch( inProperties.Type() )
{
case SignalType::int16:
case SignalType::int32:
case SignalType::float32:
case SignalType::float64:
/* These types are OK */
break;
default:
bcierr << inProperties.Type().Name()
<< " data type unsupported for BCI2000 files"
<< endl;
}
…
BCI2000OutputFormat::Write( ostream& os, const GenericSignal& inSignal, const StateVector& inStatevector )
{
switch( mInputProperties.Type() )
{
case SignalType::int16:
PutBlock<SignalType::int16>( os, inSignal, inStatevector );
break;
case SignalType::float32:
PutBlock<SignalType::float32>( os, inSignal, inStatevector );
break;
case SignalType::int32:
PutBlock<SignalType::int32>( os, inSignal, inStatevector );
break;
case SignalType::float64:
PutBlock<SignalType::float64>( os, inSignal, inStatevector );
break;
default:
bcierr << "Unsupported signal data type" << endl;
}
}
…
____________________________________________________________________________
BCI2000FileReader.cpp
…
if( isBigEndian )
{
switch( mSignalType )
{
case SignalType::int16:
value = ReadValue_SwapBytes<int16_t>( address );
break;
case SignalType::int32:
value = ReadValue_SwapBytes<int32_t>( address );
break;
case SignalType::float32:
value = ReadValue_SwapBytes<float32_t>( address );
break;
case SignalType::float64:
value = ReadValue_SwapBytes<float64_t>( address );
break;
default:
break;
}
}
else
{ // Little endian machine
switch( mSignalType )
{
case SignalType::int16:
value = ReadValue<int16_t>( address );
break;
case SignalType::int32:
value = ReadValue<int32_t>( address );
break;
case SignalType::float32:
value = ReadValue<float32_t>( address );
break;
case SignalType::float64:
value = ReadValue<float64_t>( address );
break;
default:
break;
}
}
…
____________________________________________________________________________
defines.h
…
typedef float float32_t;
typedef double float64_t;
// Backward compatibility (for new code, use stdint types):
#if 1
typedef uint8_t uint8;
typedef int8_t sint8;
typedef uint16_t uint16;
typedef int16_t sint16;
typedef uint32_t uint32;
typedef int32_t sint32;
typedef uint64_t uint64;
typedef int64_t sint64;
typedef float32_t float32;
typedef float64_t float64;
#endif
…
____________________________________________________________________________
message.h
Do we have to do changes in this file?
____________________________________________________________________________
topsocket.c
Do we have to do changes in this file?
____________________________________________________________________________
swapbytes.c
Do we have to do changes in this file?
____________________________________________________________________________
swapbytes.h
Do we have to do changes in this file?
____________________________________________________________________________
GenericSignal.h
…
template<> void
GenericSignal::PutValueBinary<SignalType::int16>( std::ostream&, size_t, size_t ) const;
template<> void
GenericSignal::PutValueBinary<SignalType::int32>( std::ostream&, size_t, size_t ) const;
template<> void
GenericSignal::PutValueBinary<SignalType::float24>( std::ostream&, size_t, size_t ) const;
template<> void
GenericSignal::PutValueBinary<SignalType::float32>( std::ostream&, size_t, size_t ) const;
template<> void
GenericSignal::PutValueBinary<SignalType::float64>( std::ostream&, size_t, size_t ) const;
template<> void
GenericSignal::GetValueBinary<SignalType::int16>( std::istream&, size_t, size_t );
template<> void
GenericSignal::GetValueBinary<SignalType::int32>( std::istream&, size_t, size_t );
template<> void
GenericSignal::GetValueBinary<SignalType::float24>( std::istream&, size_t, size_t );
template<> void
GenericSignal::GetValueBinary<SignalType::float32>( std::istream&, size_t, size_t );
template<> void
GenericSignal::GetValueBinary<SignalType::float64>( std::istream&, size_t, size_t );
…
____________________________________________________________________________
GenericSignal.cpp
I don’t know what it should be modified.