SIGN IN YOUR ACCOUNT TO HAVE ACCESS TO DIFFERENT FEATURES

FORGOT YOUR PASSWORD?

FORGOT YOUR DETAILS?

AAH, WAIT, I REMEMBER NOW!
  • LOGIN

ProtoSupplies

  • HOME
  • SHOP
    • Arduino, Teensy & IOT
    • Audio & Video
    • Breadboards & Supplies
    • Breakout Modules
    • Cables and Wires
    • Communications & Interfacing
    • Connectors & Headers
    • Displays, LEDs & Panel Meters
    • Fans & Hardware
    • ICs & Semiconductors
    • Passive Components
    • PCBs – Prototype & Adapter
    • Power Supplies & Converters
    • Proximity, Distance and Collision
    • Relays, MOSFETs & Power Ctrl
    • Robotics, Motors & Motion
    • Sensors
    • Supplies & Consumables
    • Switches & User Input
    • Temperature & Humidity
    • Test, Tools & Test Accessories
  • LEARN
  • TECH
    • Guide To Solderless Breadboards
    • Determining Unknown I2C Addresses
    • Determining LED Resistor Values
    • DC-DC Step-Down Converter Overview
    • s
  • BLOG
  • INFO
    • About Us
    • FAQ
    • My Account
    • Contact Us
  • Wishlist –
  • MY CART
    No products in cart.

Home » Tutorials » Audio Tutorials and Workshop » Audio Workshop 9

March 27, 2023

Audio Workshop 9

Audio Workshop 9

< Audio Workshop 8 – Using the Microphone
Audio Workshop 10 – Feedback (Echo) Delay

Simple Delay

You can apply real-time effects using the design tool. In this tutorial, we’ll try the delay object.

Design the Audio System

We will add an adjustable delay between the microphone input and the headset.

Draw the system shown below.

When drawing this system, be careful to use delay, not delayExt. The delayExt object uses an external RAM chip that optionally can be added to the bottom of the Audio Adapter.

The delay object has 1 input and 8 separate delay taps that can be used. We will use just one in this example.

Turn the Design into Code and Use it in a Program

You can copy and paste the code below into an IDE window. Don’t use the example in the IDE as we have deviated from that setup.

// Advanced Microcontroller-based Audio Workshop
//
// http://www.pjrc.com/store/audio_tutorial_kit.html
// https://hackaday.io/project/8292-microcontroller-audio-workshop-had-supercon-2015
// 
// Part 2-5: Simple Delay
// ProtoSupplies.com Changes and Additions:
//    Simplified design to make easier to understand.


///////////////////////////////////
// copy the Design Tool code here
///////////////////////////////////


//===============================================================================
//  Initialization
//===============================================================================
void setup() {
  Serial.begin(9600);
  AudioMemory(160);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.6);
  sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
  sgtl5000_1.micGain(36);
  delay1.delay(0, 400);
  delay(1000);
}
//===============================================================================
//  Main
//===============================================================================
void loop() {
  // do nothing
}

Now Export and copy and paste the Design Tool code into the program to complete it and verify and upload the program to the Teensy.

Now when you tap on the microphone or speak into it, you will hear the sound noticeably delayed.

Closer Look at Audio Memory

Until now, we have ignored the AudioMemory() line in the setup() function of our examples. AudioMemory() allocates all of the memory the Teensy Audio Library uses. The number you give to AudioMemory() is the total number of 128 sample buffers. Normally very little memory is required so 10 to 20 buffers are usually plenty. Each buffer consumes 260 bytes of Teensy’s RAM. You can see the impact of allocating more memory in Arduino’s console window.

Using delay() uses memory to temporarily store the data. The longer the delay, the more memory it consumes.

Modifying the Delay Time

In setup() the delay tap 0 that we are using is set for an output delay of 400 millisecond. Try changing this parameter to hear a longer delay such as 800ms.

You may notice that the background noise heard in the headset is is now being chopped up as it runs out of the available memory to store the complete 800 millisecond length of audio data and tapping or speaking into the microphone no longer works as you expect. With a delay of twice as long, try doubling the AudioMemory() to 320 to see if that corrects the issue.

Next up, we’ll take a look at using feedback with the delay object to create an echo effect.

< Audio Workshop 8 – Using the Microphone
Audio Workshop 10 – Feedback (Echo) Delay

PRODUCT SEARCH

PRODUCT CATEGORIES

  • Arduino, Teensy & IOT
  • Audio & Video
  • Breadboards & Supplies
  • Breakout Modules
  • Cables & Wires
  • Communications & Interfacing
  • Connectors & Headers
  • Displays, LEDs & Panel Meters
  • Fans & Hardware
  • ICs & Semiconductors
  • Passive Components
  • PCBs - Prototype & Adapter
  • Power Supplies & Converters
  • Proximity, Distance & Collision
  • Relays, MOSFETs & Power Ctrl
  • Robotics, Motors & Motion
  • Sensors
  • Supplies & Consumables
  • Switches & User Input
  • Temperature & Humidity
  • Test, Tools & Test Accessories

Pay Additional Charges

Dollar SignClick to add additional charges to your order

Recent Blog Entries

  • Prototyping System for Teensy 4.1 Baseboard

    Prototyping System for Teensy 4.1 Now Available

    It’s hard not to love the Teensy 4.1 with its 6...
  • Teensy 4.1 Fully Loaded

    Teensy 4.1 Fully Loaded Products Available

    As we expand our Teensy product offerings, we n...

Like Us On Facebook

Fine Print

  • Terms of Service
  • Shipping & Returns
credit-card-paypal-logos
RapidSSL_SEAL-90x50

GET IN TOUCH

Email: support@protosupplies.com

ProtoSupplies.com
Veteran Owned and Operated
Lake Stevens WA 98258, USA

  • Terms of Service
  • Shipping & Returns

© 2022 All rights reserved.

TOP