Ignotus-mago / PixelAudio

PixelAudio maps arrays of audio samples onto arrays of pixel values.
Other
0 stars 0 forks source link

Array bounds checking in PixelAudioMapper #14

Open Ignotus-mago opened 4 months ago

Ignotus-mago commented 4 months ago

Clearly this is going to be the biggest error source. We need to consider how arguments img or sig, signalPos, and length can result in out of bounds errors. Here are some ideas.

General transcoding tools:

  1. Transcode an audio sample array to RGB (with channel specified) or an RGB array to audio range.
  2. With two arrays supplied, source and target, typically we'll write signal to RGB or RGB channel to RGB. They should be the same size.

For write methods that accept both a source (signal or image) and a target (signal or image) and optionally a channel (where applicable):

  1. Source and target are the same size but not necessarily the size of the LUTs, which are not used.
  2. Source, target, and LUTs are the same size
  3. Target is the same size as LUTs and source is either the same size or smaller

For read methods:

  1. Source, array index position and length arguments must be consistent
  2. If position is less than source length but position + length exceeds source length, post a warning and trim length or pad the return array with zeros
  3. if position exceeds source length, throw an error.