Avatar for user73560

user73560

Member since Feb 2017 • Last active Sep 2018
  • 10 conversations
  • 94 comments

Most recent activity

    • 43 comments
    • 1,242 views
  • Avatar for user73560

    Hi @Gordon,

    Adding the two results for one seconds works better for me with 200Hz test.

    var p=0, sBuff=new Uint8Array(2), sN=new Uint8Array(2);
    function soundTest() {
      var w = new Waveform(512,{doubleBuffer:true,bits:16}­);
      var a = new Uint16Array(512);
      w.on("buffer", function(buf) {
        a.set(buf);
        E.FFT(a);
        var m=0,n=-1;
        for (var i=50;i<250;i++)if(a[i]>n)n=a[m=i];
        sBuff[p]=m;
        sN[p]=n;
        if(p==1){
          var avgF=E.sum(sBuff);
          var nAvg=E.sum(sN);
          console.log(avgF+"Hz @ "+nAvg);
          p=0;
        } else {
          p=1;
        }
      });
      w.startInput(D2,1024,{repeat:true});
    }
    

    Do you know what is the accuracy loss on doubling the input sound compared to the buffer we have for processing ?

  • Avatar for user73560

    Hi @Gordon,

    In order to calculate 400Hz when such frequency is produced, should I gather(concat) the two buffers for once second and then run FTT over them ?

  • Avatar for user73560

    Hi @Gordon,

    I did some tests on point one above, it appeared that when you have:

    1) Input at 512Hz with 512 buffer size restricting frequencies between 100Hz and 250Hz.

    * Produce 200Hz sine wave audio frequency, then every thing is correctly determined - 200Hz @ XXX
    

    2) Input at 1024Hz with 512 buffer size restricting frequencies between 100Hz and 500Hz.

     * Produce 200Hz sine wave audio frequency, then you have - 100Hz @ XXX as buffer is received twice per second
     * Produce 400Hz sine wave audio frequency, then you have - 200Hz @ XXX as buffer is received twice per second
    

    How can the correct frequency be determined from point 2 above ?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user73560

    Hi @Gordon,
    1) You mean this code can still measure 500Hz with lower accuracy ?

    var w = new Waveform(512,{doubleBuffer:true,bits:16}­);
    var a = new Uint16Array(512);
    w.on("buffer", function(buf) {
      a.set(buf);
      E.FFT(a);
      var m=0,n=-1;
      for (var i=100;i<500;i++)if(a[i]>n)n=a[m=i];
      console.log(m.toFixed(0)+"Hz @ "+n);
    });
    w.startInput(D2,512,{repeat:true});
    

    2) Is it possible to use 1024 buffer size on behalf of other functionalities ?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user73560

    Hi @Gordon,

    I am running with firmware 1v99.50 and trying run your example at https://www.espruino.com/Waveform

    var w = new Waveform(1024,{doubleBuffer:true,bits:16­});
    var a = new Uint16Array(1024);
    w.on("buffer", function(buf) {
      a.set(buf);
      E.FFT(a);
      var m=0,n=-1;
      for (var i=100;i<500;i++)if(a[i]>n)n=a[m=i];
      console.log(m.toFixed(0)+"Hz @ "+n);
    });
    w.startInput(D2,1024,{repeat:true});
    

    but have :
    ***Uncaught Error: Insufficient stack for computing FFT
    at line 8 col 12

    E.FFT(a);***
    

    Is it possible to measure 500Hz frequency or we are restricted by the Puck's memory ?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user73560

    Hi @Gordon,

    How should I interpret the returned Uint16Array buf in order to play it with javascript in the web browser for example ?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user73560

    Hi @Gordon,

    On Pi I gather the data via the built-in bluetooth and once per hour switch on the 3G modem to send data into the cloud and then switch it off.

    Do you think that 3G modem could impact the bluetooth range ?
    Do you think an additional BLE dongle could improve gathering the data ?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user73560

    Hi @Gordon,

    All my tests are done with NRF.setTxPower(4).
    Currently my server is Raspberry Pi 3 Model B with Bluetooth 4.2, but in future plan to use mobile phones or devices with Bluetooth5, because the range is an issue.

    As nRF52832 has Bluetooth5/ANT/2.4GHz, maybe I have to wait till the default build of Puck.js firmware is done with SDK14 and tested enough ?

    Do you think in this direction ?

    • 4 comments
    • 128 views
Actions