Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

204
Visualizações
Setting Javascript objects to use Int8 and Int16

I've got a very large datastructure, part of which shown below.

var Data =
    {
        MIDISource          : {id: 0, val: 1, harm: 0},         

        MIDIChannel         : {id: 1, val: 1, harm: 1},         
        MIDISplit           : {id: 2, val: 0, harm: 1},
        MultiTouch          : {id: 3, val: 1, harm: 1},
        TouchFreq           : {id: 4, val: 0, harm: 1},
        TouchLevel          : {id: 5, val: 0, harm: 1},
        TouchAttack         : {id: 6, val: 0, harm: 1},
        PitchWheelSens      : {id: 7, val: 0, harm: 1},
        ModWheelTarg        : {id: 8, val: 0, harm: 1},
        ModWheelSens        : {id: 9, val: 0, harm: 1},

        Fundamental         : {id: 21, val: 1, harm: 2},
        EvenHarmonics       : {id: 22, val: 1, harm: 2},
        
       // etc for about 5000 more datapoints


    };

All datapoints are accessed as for example

Data.EvenHarmonics[harm].val

id can be any value from 0 to 127, as can harm, both being fixed for each datapoint. Val can be any value from 0 to 2047. At present I assume each id, harm and val are stored however normal Javascript variables are stored, and it runs fine.

However I also have some large arrays of audio data and found changing these to use Float32 definitely speeded things up, for example

const _SineTableMax = 2047;
var SineLevels = new Float32Array(128 * (_SineTableMax + 1));

I thus wondered if I could store each point of Data in a single 32 bit location, id and harm as Int8 and val as Int16. But I can't see an obvious way of mapping Data in this manner.

Any suggestions ?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda