Git Product home page Git Product logo

Comments (5)

technoblogy avatar technoblogy commented on August 29, 2024

Here's a simple version:

void beep (int freq, int duration) {
  I2S.setAllPins(7, 5, 6, 6, 6); // sckPin, fsPin, sdPin, outSdPin, inSdPin
  const int samplerate = 8000;
  int halfwave = samplerate / freq, amplitude = 500;
  unsigned long start = millis();
  if (!I2S.begin(I2S_PHILIPS_MODE, samplerate, 16)) return; // Error
  while (millis() < start + duration) {
    if (count % halfwave == 0) amplitude = -1 * amplitude;
    I2S.write(amplitude); I2S.write(amplitude);
  }
  I2S.end();
}

The frequency is in Hz and the duration in milliseconds.

from t-deck.

spleenware avatar spleenware commented on August 29, 2024

Which header files are needed, and how is I2S object constructed? (specifically for ESP32/T-Deck target)

from t-deck.

technoblogy avatar technoblogy commented on August 29, 2024

You need:

#include <I2S.h>

I also found I needed this:

#include "soc/periph_defs.h" // Not sure why necessary

It's based on the SimpleTone example which is in the ESP32 core at:

/Users/david/Library/Arduino15/packages/esp32/hardware/esp32/2.0.12/libraries/I2S/examples/SimpleTone

from t-deck.

spleenware avatar spleenware commented on August 29, 2024

Ah, thank you. I hear a beep now! :-)

from t-deck.

aaron-924 avatar aaron-924 commented on August 29, 2024

Is there a reason why "Play MP3" doesn't work in the UnitTest code?

from t-deck.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.