Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Cinder Creative Coding Cookbook

You're reading from  Cinder Creative Coding Cookbook

Product type Book
Published in May 2013
Publisher Packt
ISBN-13 9781849518703
Pages 352 pages
Edition 1st Edition
Languages
Concepts

Table of Contents (19) Chapters

Cinder Creative Coding Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started 2. Preparing for Development 3. Using Image Processing Techniques 4. Using Multimedia Content 5. Building Particle Systems 6. Rendering and Texturing Particle Systems 7. Using 2D Graphics 8. Using 3D Graphics 9. Adding Animation 10. Interacting with the User 11. Sensing and Tracking Input from the Camera 12. Using Audio Input and Output Index

Adding a delay effect


In this recipe, we will learn how to add a delay effect to the frequency modulation audio generated in the previous recipe.

Getting ready

We will use the source code from the previous recipe, Generating sound with frequency modulation.

How to do it…

We will store our audio values and play them after an interval to achieve a delay effect using the following steps:

  1. Add the following member variables:

    int mDelay;
    float mMix, mFeedback;
    vector<float> mDelayLine;
    int mDelayIndex;
    int mDelaySize;

    Let's initialize the variables created above and initialize our delay line with zeros.

    Then add the following in the setup method:

    mDelay = 200;
    mMix = 0.2f;
    mFeedback = 0.3f;
    mDelaySize = mDelay * 44.1f;
    for( int i=0; i<mDelaySize; i++ ){
     mDelayLine.push_back( 0.0f );
    }
  2. In the implementation of our audioCallback method, we will read back from the buffer the values that were generated in the frequency modulation and calculate the delay.

    The final value is again passed into the buffer...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}