Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong value types & added typescript decorators & some refactoring #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Vovencia
Copy link

@Vovencia Vovencia commented Jan 29, 2021

In this code has some wrongs (block 1):

    var reads = [
      ['riff_head', 'string', 4],
      ['chunk_size','uinteger', 4],
      ['wave_identifier', 'string', 4],
      ['fmt_identifier', 'string', 4],
      ['subchunk_size','integer',4],
      ['audio_format','integer',2],
      ['num_channels','integer',2],
      ['sample_rate','uinteger',4],
      ['byte_rate','integer',4],
      ['block_align','integer',2],
      ['bits_per_sample','integer',2],
      //['uhm','integer',2],
      ['data_identifier','string', 4],
      //['sub_chunk2_size', 'integer', 4],

    ]

And this (block 2):

else if(read[1]=='integer'){

          read_result[read[0]] = buffer.readUInt16LE(pointer, read[2])
          pointer = pointer + read[2];
        }
        else if(read[1]=='uinteger'){

          read_result[read[0]] = buffer.readInt32LE(pointer, read[2])
          pointer = pointer + read[2];
        }

there is some confusion here..

All int values should be unsigned: readUInt32LE not readInt32LE

int16 = 2 bytes
int32 = 4 bytes

in block 1 some types incorrent by int size

So.. to avoid confusion, i am change type names:
uint16 name for 2 bytes int & uint32 name for 4 bytes int

In you logic, integer -> 2 bytes, uinteger - 4 bytes

Block description 1:

here:
['subchunk_size','integer',4],
type is 2 bytes ( integer ), but real size 4 bytes

and here:
['byte_rate','integer',4],

P.S.
Sorry for my english..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant