Example #1
0
        /*
         * JAIV1 Oscillator Format
         * 0x00 - byte mode
         * 0x01 - byte[3] unknown
         * 0x04 - float rate
         * 0x08 - int32 attackVectorOffset
         * 0x0C - int32 releaseVectorOffset
         * 0x10 - float width
         * 0x14 - float vertex
         */
        public JOscillator loadOscillator(BeBinaryReader binStream, int Base)
        {
            var Osc    = new JOscillator();                                      // Create new oscillator
            var target = binStream.ReadByte();                                   // load target -- what is it affecting?

            binStream.BaseStream.Seek(3, SeekOrigin.Current);                    // read 3 bytes?
            Osc.rate = binStream.ReadSingle();                                   // Read the rate at which the oscillator progresses -- this will be relative to the number of ticks per beat.
            var attackSustainTableOffset = binStream.ReadInt32();                // Offset of AD table
            var releaseDecayTableOffset  = binStream.ReadInt32();                // Offset of SR table

            Osc.Width  = binStream.ReadSingle();                                 // We should load these next, this is the width, ergo the value of the oscillator at 32768.
            Osc.Vertex = binStream.ReadSingle();                                 // This is the vertex, the oscillator will always cross this point.
            // To determine the value of an oscillator, it's Vertex + Width*(value/32768) -- each vector should progress the value, depending on the mode.
            if (attackSustainTableOffset > 0)                                    // first is AS table
            {
                binStream.BaseStream.Position = attackSustainTableOffset + Base; // Seek to the vector table
                Osc.envelopes[0] = readEnvelope(binStream, Base);                // Load the table
            }
            if (releaseDecayTableOffset > 0)                                     // Next is RD table
            {
                binStream.BaseStream.Position = releaseDecayTableOffset + Base;  // Seek to the vector and load it
                Osc.envelopes[1] = readEnvelope(binStream, Base);                // loadddd
            }
            Osc.target = (JOscillatorTarget)target;
            return(Osc);
        }
Example #2
0
        /*
         * JAIV2 Oscillator Structure
         * 0x00 - int32 0x4F736369 'Osci'
         * 0x04 - byte mode
         * 0x05 - byte[3] unknown
         * 0x08 - float rate
         * 0x0c - int32 attackVectorOffset (RELATIVE TO ENVT + 0x08)
         * 0x10 - int32 releaseVectorOffset (RELATIVE TO ENVT + 0x08)
         * 0x14 - float width
         * 0x18 - float vertex
         */

        /* NOTE THAT THESE OSCILLATORS HAVE THE SAME FORMAT AS JAIV1, HOWEVER THE VECTORS ARE IN THE ENVT */
        public JOscillator loadOscillator(BeBinaryReader binStream, int EnvTableBase)
        {
            var Osc = new JOscillator();       // Create new oscillator

            if (binStream.ReadInt32() != Osci) // Read first 4 bytes
            {
                throw new InvalidDataException("Oscillator format is invalid. " + binStream.BaseStream.Position);
            }

            var target = binStream.ReadByte();                    // load target -- what is it affecting?

            binStream.BaseStream.Seek(3, SeekOrigin.Current);     // read 3 bytes?
            Osc.rate = binStream.ReadSingle();                    // Read the rate at which the oscillator progresses -- this will be relative to the number of ticks per beat.
            var attackSustainTableOffset = binStream.ReadInt32(); // Offset of AD table
            var releaseDecayTableOffset  = binStream.ReadInt32(); // Offset of SR table

            Osc.Width  = binStream.ReadSingle();                  // We should load these next, this is the width, ergo the value of the oscillator at 32768.
            Osc.Vertex = binStream.ReadSingle();                  // This is the vertex, the oscillator will always cross this point.
            // To determine the value of an oscillator, it's Vertex + Width*(value/32768) -- each vector should progress the value, depending on the mode.
            // We need to add + 8 to the offsets, because the pointers are the offset based on where the data starts, not the section
            if (attackSustainTableOffset > 0)                                                // first is AS table
            {
                binStream.BaseStream.Position = attackSustainTableOffset + EnvTableBase + 8; // Seek to the vector table
                Osc.envelopes[0] = readEnvelope(binStream, EnvTableBase + 8);                // Load the table
            }
            if (releaseDecayTableOffset > 0)                                                 // Next is RD table
            {
                binStream.BaseStream.Position = releaseDecayTableOffset + EnvTableBase + 8;  // Seek to the vector and load it
                Osc.envelopes[1] = readEnvelope(binStream, EnvTableBase + 8);                // loadddd
            }
            Osc.target = OscillatorTargetConversionLUT[target];
            return(Osc);
        }
Example #3
0
 public void setOcillator(JOscillator osc)
 {
     instOsc = osc;
 }