• RE: Digital Microphones and Arduino

    Hi @atw72

    Could you try the following and see what the outcome is?

    #include <SDHCI.h>
    #include <Audio.h>
    
    SDClass theSD;
    AudioClass *theAudio;
    
    File myFile;
    
    bool ErrEnd = false;
    
    
    /**
       @brief Audio attention callback
    
       When audio internal error occurc, this function will be called back.
    */
    
    static void audio_attention_cb(const ErrorAttentionParam *atprm)
    {
      puts("Attention!");
    
      switch (atprm->error_code) {
        case AS_ATTENTION_CODE_INFORMATION:
        case AS_ATTENTION_CODE_WARNING    :
          ErrEnd = false;
          break;
        case AS_ATTENTION_CODE_ERROR      :
        case AS_ATTENTION_CODE_FATAL      :
        default:
          ErrEnd = true;
    
      }
    }
    
    /**
       @brief Setup recording of mp3 stream to file
    
       Select input device as microphone <br>
       Initialize filetype to stereo mp3 with 48 Kb/s sampling rate <br>
       Open "Sound.mp3" file in write mode
    */
    
    static const int32_t recoding_frames = 400;
    static const int32_t recoding_size = recoding_frames * 288; /* 96kbps, 1152sample */
    
    void setup()
    {
      theAudio = AudioClass::getInstance();
    
      theAudio->begin(audio_attention_cb);
    
      puts("initialization Audio Library");
    
      /* Select input device as microphone */
      theAudio->setRecorderMode(AS_SETRECDR_STS_INPUTDEVICE_MIC, AS_MICGAIN_HOLD, 68, true);
      
    
      /*
         Initialize filetype to stereo mp3 with 48 Kb/s sampling rate
         Search for MP3 codec in "/mnt/sd0/BIN" directory
      */
      theAudio->initRecorder(AS_CODECTYPE_MP3, "/mnt/sd0/BIN", AS_SAMPLINGRATE_48000, AS_CHANNEL_STEREO);
      puts("Init Recorder!");
    
      /* Open file for data write on SD card */
      myFile = theSD.open("sound.mp3", FILE_WRITE);
    
        /* Verify file open */
      if (!myFile)
      {
        printf("File open error\n");
        exit(1);
      }
    
      theAudio->startRecorder();
      puts("Recording Start!");
    }
    
    /**
       @brief Record given frame number
    */
    void loop()
    {
      err_t err;
      /* recording end condition */
      if (theAudio->getRecordingSize() > recoding_size)
      {
        theAudio->stopRecorder();
        sleep(1);
        err = theAudio->readFrames(myFile);
    
        goto exitRecording;
      }
    
      /* Read frames to record in file */
      err = theAudio->readFrames(myFile);
    
      if (err != AUDIOLIB_ECODE_OK)
      {
        printf("File End! =%d\n", err);
        theAudio->stopRecorder();
        goto exitRecording;
      }
    
      if (ErrEnd)
      {
        printf("Error End\n");
        theAudio->stopRecorder();
        goto exitRecording;
      }
    
      /* This sleep is adjusted by the time to write the audio stream file.
         Please adjust in according with the processing contents
         being processed at the same time by Application.
      */
      //  usleep(10000);
    
      return;
    
    exitRecording:
    
      theAudio->closeOutputFile(myFile);
      myFile.close();
    
      theAudio->setReadyMode();
      theAudio->end();
    
      puts("End Recording");
      exit(1);
    }
    
    
    posted in Spresense
  • RE: audio scope

    Hi @JCPStevens ,

    Ok, let's sort this out once for all.

    I did the following on a Ubuntu machine to get this to work:

    git clone --recursive git@github.com:TE-KarlKomierowski/hackster_projects.git
    
    

    After that I opened Arduino IDE and from the Sketch menu I took Include library->Add .ZIP library
    In the file browser I selected the folder in the git repo as follows:

    ~/hackster_projects/spresense-audio-scope/arduino-lib
    I selected TFT folder and clicked OK

    I then opened arduino-scope-ino in the Arduino IDE and pressed the button Verify to build the sketch.

    This failed. It turns out that the TFT library defines a macro that is named swap and this is later being used in other libraries which confuses the build system.

    The quickes way to get around this for me was to simply add the following on line 7 to the arduino-scope.ino sketch:

    #undef swap
    

    The undef part must be between the include <TFT> and include <Audio.h>

    #include <TFT.h> /* Include TFT.h first, then Audio.h to avoid __SD_H__ being defined in the Audio.h. */
    #undef swap
    #include <Audio.h>
    

    After doing this I can build the sketch.
    I have been using a Ubuntu PC with Arduino IDE version 1.8.9.

    I have built for target Spresense.

    Hope that this will work for you too.
    If you run into problems, please past your errorlog into your post and I will try to help out.

    posted in Spresense
  • RE: NNC

    @CGM11 said in NNC:

    @TE-KarlKomierowski Sorry Karl, I didn't see your answer. But as I told you, it is good for other people to know it as well, the NNC works pretty fine in a MacBook Pro using Parallels.

    Regards and thank you.

    Hi @CGM11

    Ok, thank you for the information!

    Br
    /Karl

    posted in Spresense
  • RE: Batteries / Consumption and Safety

    Hi @CGM11 ,

    I can't give you an official "go" from Sony for your configuration (safety policies and regulations).

    But I can advice and lift that there is an increased risk by combining multiple cells in parallel.
    The "Battery University" site have a site that provides information about this.

    https://batteryuniversity.com/learn/article/serial_and_parallel_battery_configurations

    Hope this will help you to take the most suitable decision for your project.

    posted in Spresense
  • RE: Digital Microphones and Arduino

    Hi @atw72

    I checked the code in media_recorder/audio_recorder_sink.cpp
    and the warning on line 84 is in this function AudioRecorderSink::write this:
    AS_ATTENTION_SUB_CODE_SIMPLE_FIFO_OVERFLOW

    Attention: module[4][0] attention id[1]/code[6] (objects/media_recorder/audio_recorder_sink.cpp L84)

    Could you share your sketch with us and it will be easier to see all the settings that have been used when this warning occurred.

    And also, do you use an SD card? What type/brand is it?

    Thank you.
    BR
    Karl

    posted in Spresense
  • RE: How to insall software correct for Spresense Audio-Scope

    Hi @JCPStevens

    I followed your description and to get this to work correctly you have be able to clone this repository without errors:

    $ git clone --recursive git@github.com:TE-KarlKomierowski/hackster_projects.git
    

    I don't know why you get a permission denied.
    You could try to use https too and see if it helps:

    $ git clone --recursive https://github.com/TE-KarlKomierowski/hackster_projects.git
    
    posted in Spresense
  • RE: Writing directly to image Framebuffer - Spresense SDK

    @Cameron-R-MANN

    I've been able to increment the address and write 0xFFFF to several locations, drawing a white line across the screen. As I expected, the line itself does not flicker when overlaid across the camera stream, while my NuttX graphic primitive continues to "flicker" (redrawn). I would say it is good progress, but I was uncertain if this is the "correct" approach to my problem. I will continue to investigate the usability/stability of this method.....

    A good approach would be to use the NX graphic functions to write directly to the camera stream buffer before it is pushed to the display. I guess that there are people with Nuttx nx experience that have a good answer to on how to setup a framebuffer with NX. I would really like to use it my self since it is very slow to write every line/or text directly to the display.

    If you figure this one out, I would really appreciate if you could update this thread with that info! It would be nice to use the present NX functions in Nuttx instead of writing custom graphic functions.

    posted in Spresense
  • RE: Writing directly to image Framebuffer - Spresense SDK

    Hi @Cameron-R-MANN

    I assume that you are using the ILI934x display?
    I think that the nx system can write both directly to the display but also through a framebuffer, but I am not sure on how to configure that. I don't want to say too much because at the moment I am not 100% sure of the details.

    But one thing that can help you to speed up writes to the display is to enable DMA for the SPI TX, this is done via menuconfig.

    CXD56xx Configuration  ---> 
    SPI[X ]
    DMAC support for SPI[X] TX
    

    And also to increase the SPI frequency, this I do by modifying the file:
    sdk/bsp/board/spresense/include/board.h

    #define ILI9340_SPI_MAXFREQUENCY    40000000
    
    posted in Spresense
  • RE: DigitalRead()

    Hi @JCPStevens

    By default, when the mode is set to INPUT, the pin state is HIGH. If you want to change it to LOW, change the pin state to LOW.

    You can use my example below:

    int left=0;
    int right=0;
    
    void setup() {
    pinMode(4,INPUT);
    pinMode(6,INPUT);
    digitalWrite(4, LOW);
    digitalWrite(6, LOW);
    Serial.begin(115200);
    }
    
    void loop() {
    left=digitalRead(4);
    right=digitalRead(6);
    if (left==(HIGH)){
    Serial.println("Left=High");}
    if (left==(LOW)){
    Serial.println("Left=low");}
    if (right==(HIGH)){
    Serial.println("Right=high");}
    if (right==(LOW)){
    Serial.println("Right=low");}
    }
    
    posted in Spresense
  • RE: DigitalRead()

    Hi @JCPStevens

    What is physically connected to the pins 4 and 6?

    Br
    Karl

    @JCPStevens said in DigitalRead():

    left=digitalRead(4);
    right=digitalRead(6);

    posted in Spresense