Pattern::Pattern( IO::File &file ) { DataLength = file.Read16(); Rows = file.Read16(); file.Skip( 4 ); // reserved Data = new u8[ DataLength ]; for( int i = 0; i < DataLength; i++ ) { Data[i] = file.Read8(); } }
void IMU::loadCalibrationData(IO::File& calibrationFile) { calibrationFile.setEndianness(Misc::LittleEndian); /* Read the accelerometer matrix: */ for(int i=0;i<3;++i) for(int j=0;j<4;++j) calibrationData.accelerometerMatrix(i,j)=Scalar(calibrationFile.read<Misc::Float64>()); // DEBUGGING std::cout<<"Accelerometer matrix: "<<calibrationData.accelerometerMatrix<<std::endl; /* Read the gyroscope matrix: */ for(int i=0;i<3;++i) for(int j=0;j<4;++j) calibrationData.gyroscopeMatrix(i,j)=Scalar(calibrationFile.read<Misc::Float64>()); // DEBUGGING std::cout<<"Gyroscope matrix: "<<calibrationData.gyroscopeMatrix<<std::endl; if(calibrationData.magnetometer) { /* Read the magnetometer matrix: */ for(int i=0;i<3;++i) for(int j=0;j<4;++j) calibrationData.magnetometerMatrix(i,j)=Scalar(calibrationFile.read<Misc::Float64>()); // DEBUGGING std::cout<<"Magnetometer matrix: "<<calibrationData.magnetometerMatrix<<std::endl; } }
void glCompileShaderFromFile(GLhandleARB shaderObject,const char* shaderSourceFileName,IO::File& shaderSourceFile) { /* Read the entire shader source: */ size_t shaderAllocSize=8192; GLcharARB* shaderSource=new GLcharARB[shaderAllocSize]; size_t shaderSourceLength=0; while(!shaderSourceFile.eof()) { /* Make room in the shader source buffer: */ if(shaderSourceLength==shaderAllocSize) { shaderAllocSize=(shaderAllocSize*3)/2; GLcharARB* newShaderSource=new GLcharARB[shaderAllocSize]; memcpy(newShaderSource,shaderSource,shaderSourceLength); delete[] shaderSource; shaderSource=newShaderSource; } /* Read more data from the file: */ size_t numBytesRead=shaderSourceFile.readUpTo(shaderSource+shaderSourceLength,shaderAllocSize-shaderSourceLength); shaderSourceLength+=numBytesRead; } /* Upload the shader source into the shader object: */ const GLcharARB* ss=shaderSource; GLint ssl=GLint(shaderSourceLength); glShaderSourceARB(shaderObject,1,&ss,&ssl); delete[] shaderSource; /* Compile the shader source: */ glCompileShaderARB(shaderObject); /* Check if the shader compiled successfully: */ GLint compileStatus; glGetObjectParameterivARB(shaderObject,GL_OBJECT_COMPILE_STATUS_ARB,&compileStatus); if(!compileStatus) { /* Get some more detailed information: */ GLcharARB compileLogBuffer[2048]; GLsizei compileLogSize; glGetInfoLogARB(shaderObject,sizeof(compileLogBuffer),&compileLogSize,compileLogBuffer); /* Signal an error: */ Misc::throwStdErr("glCompileShaderFromFile: Error \"%s\" while compiling shader %s",compileLogBuffer,shaderSourceFileName); } }
void LensDistortionParameters::write(IO::File& file) const { file.setEndianness(Misc::LittleEndian); file.write<double>(center.getComponents(),2); file.write<double>(radiusScale2); file.write<double>(kappa,2); file.write<double>(rho,3); }
void Sample::LoadData( IO::File &file ) { if( !Compressed ) { // subtract offset for unsigned samples int offset = (Convert&1) ? 0 : (Data.Bits16 ? -32768 : -128); // signed samples if( Data.Bits16 ) { Data.Data16 = new s16[ Data.Length ]; for( int i = 0; i < Data.Length; i++ ) { Data.Data16[i] = file.Read16() + offset; } } else { Data.Data8 = new s8[ Data.Length ]; for( int i = 0; i < Data.Length; i++ ) { Data.Data8[i] = file.Read8() + offset; } } } else { // TODO : accept compressed samples. } }
void GLFont::CharInfo::read(IO::File& file) { file.read(width); file.read(ascent); file.read(descent); file.read(glyphOffset); file.read(rasterLineOffset); file.read(spanOffset); }
Envelope::Envelope( IO::File &file ) { u8 FLG = file.Read8(); Enabled = !!(FLG & 1); Loop = !!(FLG & 2); Sustain = !!(FLG & 4); IsFilter = !!(FLG & 128); Length = file.Read8(); LoopStart = file.Read8(); LoopEnd = file.Read8(); SustainStart = file.Read8(); SustainEnd = file.Read8(); for( int i = 0; i < 25; i++ ) { Nodes[i].y = file.Read8(); Nodes[i].x = file.Read16(); } }
Sample::Sample( IO::File &file ) { file.Skip(4); // IMPS DOSFilename[12] = 0; for( int i = 0; i < 12; i++ ) DOSFilename[i] = file.Read8(); file.Skip(1); // 00h GlobalVolume = file.Read8(); u8 Flags = file.Read8(); HasSample = !!(Flags & 1); Data.Bits16 = !!(Flags & 2); Stereo = !!(Flags & 4); Compressed = !!(Flags & 8); Data.Loop = !!(Flags & 16); Data.Sustain = !!(Flags & 32); Data.BidiLoop = !!(Flags & 64); Data.BidiSustain = !!(Flags & 128); DefaultVolume = file.Read8(); Name[26] = 0; for( int i = 0; i < 26; i++ ) Name[i] = file.Read8(); Convert = file.Read8(); DefaultPanning = file.Read8(); Data.Length = file.Read32(); Data.LoopStart = file.Read32(); Data.LoopEnd = file.Read32(); Data.C5Speed = file.Read32(); Data.SustainStart = file.Read32(); Data.SustainEnd = file.Read32(); u32 SamplePointer = file.Read32(); VibratoSpeed = file.Read8(); VibratoDepth = file.Read8(); VibratoRate = file.Read8(); VibratoForm = file.Read8(); file.Seek( SamplePointer ); LoadData( file ); }
Instrument::Instrument( IO::File &file ) { file.Skip(4); // IMPI DOSFilename[12] = 0; for( int i = 0; i < 12; i++ ) DOSFilename[i] = file.Read8(); file.Skip(1); // 00h NewNoteAction = file.Read8(); DuplicateCheckType = file.Read8(); DuplicateCheckAction = file.Read8(); Fadeout = file.Read16(); PPS = file.Read8(); PPC = file.Read8(); GlobalVolume = file.Read8(); DefaultPan = file.Read8(); RandomVolume = file.Read8(); RandomPanning = file.Read8(); TrackerVersion = file.Read16(); NumberOfSamples = file.Read8(); Name[26] = 0; for( int i = 0; i < 26; i++ ) Name[i] = file.Read8(); InitialFilterCutoff = file.Read8(); InitialFilterResonance = file.Read8(); MidiChannel = file.Read8(); MidiProgram = file.Read8(); MidiBank = file.Read16(); file.Read8(); // reserved for( int i = 0; i < 120; i++ ) { Notemap[i].Note = file.Read8(); Notemap[i].Sample = file.Read8(); } VolumeEnvelope = new Envelope( file ); PanningEnvelope = new Envelope( file ); PitchEnvelope = new Envelope( file ); }