Avatar for jruroede

jruroede

Member since Aug 2018 • Last active Sep 2018
  • 1 conversations
  • 11 comments

Most recent activity

  • in Electronics
    Avatar for jruroede

    That did the trick! I play around with some of the values to try and up the quality, but I think im going to need external hardware for that. Thank you so much!

  • in Electronics
    Avatar for jruroede

    Thank you for clearing all that up! I really appreciate the fast response too, thank you for that. This is the first time im really trying to code something, im still very new to this. I had accidentally put analogWrite but I had meant to put analogRead, I thought I needed it because the signal is coming from the DC pin on mic into ADC of the espruino. When I run code you posted I get

    >[
      "System Volume Information",
      "X.raw"
     ]
    =undefined
    > 
    

    I tried playing the new file changing proper parameters and Im getting static.

  • in Electronics
    Avatar for jruroede

    It wasn't reset properly. This is the code im currently using for the voice recording using the SPW2430(microphone)

    var spi = new SPI(); 
    spi.setup({mosi:B15, miso:B14, sck:B10});
    E.connectSDCard(spi, B1);
    console.log(require("fs").readdirSync())­;
    
    require("fs").writeFileSync("X.raw");
    
    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);
      require("fs").appendFileSync("X.raw", a);
      var m=0,n=-1;
      for (var i=100;i<1000;i++)if(a[i]>n)n=a[m=i];
      console.log(m.toFixed(0)+"Hz @ "+n);
    });
    
    analogWrite(B0, 0.5, {freq:20000});
    w.startInput(B0,2000,{repeat:true});
    //w.stop();
    setInterval(function() {
      w.stop();
    },10000);
    
    

    would the Hardware drive the values for var i? meaning if my mic can record from 100Hz to 10kHz do i put i=100,i<10000?

    with the code above the IDE writes

    >[
      "System Volume Information",
    "X.raw"
     ]
    =undefined
    105Hz @ 4
    127Hz @ 6
    194Hz @ 5
    128Hz @ 5
    444Hz @ 6
    423Hz @ 5
    181Hz @ 4
    107Hz @ 6
    101Hz @ 4
    506Hz @ 22
    470Hz @ 7
    469Hz @ 8
    425Hz @ 6
    233Hz @ 7
    152Hz @ 6
    130Hz @ 5
    121Hz @ 6
    438Hz @ 7
    481Hz @ 10
    168Hz @ 6
    >
    

    I still cannot get proper voice playback so I thought maybe my sample rate needed to go up but, when I change the sample rate to 1024 in waveform and and Uint16array the IDE gives me an error code.

    in function called from system
    Uncaught Error: Insufficient stack for computing FFT
     at line 2 col 10
      E.FFT(a);
    
  • in Electronics
    Avatar for jruroede

    Okay, so after trouble shooting that im now back to my original question, regarding using SPW2430(microphone). The code you had given me works to give me non zero values from the IDE.

    var w = new Waveform(128);
    w.on("finish", function(buf) {
      for (var i in buf)
        console.log(buf[i]);
    });
    w.startInput(B0,2000,{repeat:false});
    

    How can I record for X amount of time then save it as a .raw file to an SD connected to the espruino? this is my current code but its not functioning correctly.

    var spi = new SPI(); 
    spi.setup({mosi:B15, miso:B14, sck:B10});
    E.connectSDCard(spi, B1);
    console.log(require("fs").readdirSync())­;
    
    var w = new Waveform(128, {bits:16});
    w.on("finish", function(buf) {
      require("fs").writeFileSync("sound.raw",­buf);
    });
    w.startInput(B0,2000,{repeat:false});
    
    
    

    IDE error code:

    in function called from system
    Uncaught Error: Expecting first argument to be an array, not undefined
    at line 1 col 16
    buf.set(fileBuf);
                  
    
  • in Electronics
    Avatar for jruroede

    Its slight noise, I think the hardware recommendation will fix it. Is there anyway to get volume control without adding more hardware such as a digital potentiometer?

  • in Electronics
    Avatar for jruroede

    That worked perfectly! still getting a small amount of feedback that isn't a huge deal. Any recommendations to clean up the audio signal slightly more?

  • in Electronics
    Avatar for jruroede

    Update: tried new headphone its much louder than the last one and your code worked. Though still having similar problems as before with playing a voice recording. The code we are using is posted below.

    // SD card setup
    //DI(mosi) = B15
    //DO(miso) = B14
    //CK(sck = B10
    //CS(CD pin) = B1
    var spi = new SPI(); 
    spi.setup({mosi:B15, miso:B14, sck:B10});
    E.connectSDCard(spi, B1);
    console.log(require("fs").readdirSync())­;
    
    var f = E.openFile("X-File.raw","r");
    
    var w = new Waveform(2048,  {doubleBuffer:true});
    // load first bits of sound file
    w.buffer.set(f.read(w.buffer.length));
    w.buffer2.set(f.read(w.buffer.length));
    var fileBuf = f.read(w.buffer.length);
    // when one buffer finishes playing, load the next one
    w.on("buffer", function(buf) {
      buf.set(fileBuf);
      fileBuf = f.read(buf.length);
      if (fileBuf===undefined) w.stop(); // end of file
    });
    // start output
    analogWrite(A7, 0.5);
    w.startOutput(A7,8000,{repeat:true});
    

    Where "X-File.raw" is a file I made in audacity using the guide lines provided in the waveform documentation and is in the proper format of .raw(header-less) unsigned 8-bit PCM with a 8000hz playback speed. As I play the file I can accurately make out each spoken word in the sentence however it is very fuzzy to the point where you can barely make out the words and a single high pitch tone can be heard overtop of that audio. Can you recommend anything that can possibly fix this?

  • in Electronics
    Avatar for jruroede

    I tested it and I hear no sound through the headphone. when I take a meter to it and send your code to the espruino I receive 1.59V for a short duration, which should indicate at least the signal is going through. Im using pin A7 but tried it with B3, both give me the 1.59V when code is deployed. I will try with a few different speakers I shouldn't need an amp to power a single small two wire earphone speaker right?

  • in Electronics
    Avatar for jruroede

    Update: We are using PWM to output to the speaker attached to the espruino wifi, We are trying to play files we know work that we externally put on the attached SD card, we are only receiving fluctuating frequency. We have tried changing sample rate in the waveform class as well as the frequency of the analogWrite and w.startOutput functions cant find to get one to work but it does have an effect on the audio being output through the speaker.

Actions