Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 5 1 2 3 ... LastLast
Results 1 to 25 of 102

Thread: Limits of delay effect in audio library

  1. #1

    Limits of delay effect in audio library

    Could someone tell me roughly how long a delay is possible with the delay effect in the audio library? I'm building a hardware delay line for music synthesis and wondering whether the Teensy 3.1 is appropriate for longer delays (2000ms). I realize that other code will also consume memory. For this application, the only extra code would be instructions necessary for reading controls for real-time parameter changes.

    Thanks very much for your help,
    Michael

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,700
    Quote Originally Posted by aaaxon View Post
    Could someone tell me roughly how long a delay is possible with the delay effect in the audio library?
    About half a second delay is achievable.

    The delay object consumes audio memory. Each block gives 2.9 ms. So in setup(), you'll need to use something like AudioMemory(180) to allocate enough memory. When you compile in Ardiuno, there's a summary of memory usage printed. The audio memory will consume the "global variables" memory. Buffers used by USB, SD and other stuff also consume memory. That summary is your best guide to seeing how much of the memory you're using up.

  3. #3
    Paul,

    Thanks for the quick reply! Is there a chance that the W25Q128FV memory chip could be used to extend delay time?

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,514
    Quote Originally Posted by aaaxon View Post
    Paul,

    Thanks for the quick reply! Is there a chance that the W25Q128FV memory chip could be used to extend delay time?
    No, this is flashmemory. It takes 40 secs to erase it.
    But you can use RAM. The 23lc1024 is pincompatible.
    ?..and of course, you have to write your own delay ()
    Thw RAM is more than fast enough (spi 20MHz)
    Its 128K - you could add more than one.
    Last edited by Frank B; 07-31-2015 at 04:24 PM.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,700
    Yeah, a delay object using a 23LC1024 would be awesome. That's enough memory for almost 1.5 seconds. In tandem with the normal delay object, that'd make 2 second delay possible!

    Just a small matter of programming......

  6. #6
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,514
    Quote Originally Posted by PaulStoffregen View Post
    Yeah, a delay object using a 23LC1024 would be awesome. That's enough memory for almost 1.5 seconds. In tandem with the normal delay object, that'd make 2 second delay possible!

    Just a small matter of programming......
    Maybe I do it, plus a version for the memoryboard.
    Another nice thing could also be to generate an echo .. in a virtual room , like a church, a hall, or in the mountains (with a small number of "reflection surfaces"). Not with complicated math, a more simple version would be ok too.
    But I hesitate a little to make it , I myself do not need it, and I'm no aware of any requests.
    Last edited by Frank B; 08-02-2015 at 04:46 PM.

  7. #7
    Frank,

    I'd be very grateful if you would consider doing a simple version of the code. I think it would also get a lot of interest from others who are interested in using the Audio Board for music applications.

    I'll be happy to order some memory chips and do any beta testing you might need. Are you planning to sell memoryboard PC boards? This looks as if it would allow an audio delay line even longer that 1500ms. Pretty neat.

    Thanks,
    Michael

  8. #8
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,514
    Quote Originally Posted by aaaxon View Post
    Frank,

    I'd be very grateful if you would consider doing a simple version of the code. I think it would also get a lot of interest from others who are interested in using the Audio Board for music applications.

    I'll be happy to order some memory chips and do any beta testing you might need. Are you planning to sell memoryboard PC boards? This looks as if it would allow an audio delay line even longer that 1500ms. Pretty neat.

    Thanks,
    Michael
    Hi Michael,

    Yes, i don't know if it would be useful, but the delay could be several seconds - depends on the number of RAMs.
    I already have some code for a FIFO over several RAMS - not public yet, because it's for my private mp3-streaming project.
    Do you have some time ? I don't think that i can do much before september.

    At the moment, I have no plans to sell the boards. This may change...
    But I have single spare board + parts (msg me!) Where are you from ?

    Frank

  9. #9
    Senior Member
    Join Date
    Aug 2013
    Location
    Gothenburg, Sweden
    Posts
    292
    I have ordered some DIL memory chips and will use them to build my initial setup for testing on a stripboard.

    But having six chips on one of franks memory boards would be great though.

  10. #10
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,514
    Quote Originally Posted by mlu View Post
    I have ordered some DIL memory chips and will use them to build my initial setup for testing on a stripboard.

    But having six chips on one of franks memory boards would be great though.

    If there is enough interest, I can be produced 10 or 20 boards, and ordered the other parts, possibly from China. (This will take some time, and I do not know whether the RAM are cheaper there.)
    Maybe I can also assemble a few - If you promise not to look at the solder joints.

    The boards are compatible to the PJRC Audio boards and the ILI display, same size as the Teensy. They should be placed under the Teensy (because of the program-button).

  11. #11
    I have the same question, but might be willing to go with a different approach. Is it possible to lower the bitrate or sample rate to extend the delay time? Just found this Teensy audio library and it looks incredible, really very feature rich and accessible compared to most audio libraries, but unfortunately a longer delay time is required for the particular project where I'd be keen to use it (delay pedal for guitar). I'd be wanting more than 4 seconds which might be completely unreasonable!

  12. #12
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,514
    Quote Originally Posted by dxinteractive View Post
    I have the same question, but might be willing to go with a different approach. Is it possible to lower the bitrate or sample rate to extend the delay time? Just found this Teensy audio library and it looks incredible, really very feature rich and accessible compared to most audio libraries, but unfortunately a longer delay time is required for the particular project where I'd be keen to use it (delay pedal for guitar). I'd be wanting more than 4 seconds which might be completely unreasonable!
    No.. But 4 secs fit into 3x 23LC1024 RAMs.. No problem.

  13. #13
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,700
    Frank, how would you feel about yet another minor memory board revision?

    Currently pins 8, 16, 17 are used for chip selects. Perhaps we should consider pin 4, 5, 8?

    Pins 16 & 17 are the 2 special ADC inputs that can be used with ADC0 and ADC1. All the other analog pins on the edge are ADC0 only. Future library versions will probably add a stereo ADC object using those 2 pins.

    Then again, maybe the extra memory board will be used only with the audio board?

  14. #14
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,514
    Ok, I can do a new revision. It fun to work with eagle :-)

    There is a variant 23LCV1024, would it make sense to support its "Battery Backup" feature ?

  15. #15
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,514
    Quote Originally Posted by Frank B View Post
    Ok, I can do a new revision. It fun to work with eagle :-)

    There is a variant 23LCV1024, would it make sense to support its "Battery Backup" feature ?
    Does anyone have any objection to pins 2,3,4 ?

  16. #16
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,514
    Quote Originally Posted by Frank B View Post
    Does anyone have any objection to pins 2,3,4 ?
    Ok , obviously not.

    Link to the OSH-Park shared-project:[Edit: removed]

    2 layer board of 0.73x1.42 inches (18.52x36.04mm) 5.15$ for 3.

    Edit:
    IMPORTANT: This Revision is NOT tested. I don't have it ! I ordered it yesterday, and i can say more in a few weeks.
    So, it's a bit risky to order it.
    Last edited by Frank B; 08-10-2015 at 07:18 AM.

  17. #17
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,700
    Great, I just ordered a set of 3.

  18. #18
    Member
    Join Date
    Nov 2012
    Location
    Olympia, WA
    Posts
    52
    Quote Originally Posted by Frank B View Post

    Link to the OSH-Park shared-project: https://oshpark.com/shared_projects/KZt5PaU7

    2 layer board of 0.73x1.42 inches (18.52x36.04mm) 5.15$ for 3.
    Can't wait to play with this! Eight seconds or so of sound to repeat/modulate is going to be great.

    I can infer what the six identical chips are. Is there a parts list somewhere indicating what the other two chips and caps / resistors are so I can check my parts bins before I order?

    EDIT: thanks for the parts list, Github link, and warning below. I think I'll get the parts (unlikely to change much) and wait for the verdict on the board before ordering.
    Last edited by drjohn; 08-10-2015 at 05:20 AM. Reason: impulse

  19. #19
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    8,012
    Last edited by defragster; 08-10-2015 at 06:20 AM.

  20. #20
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,514
    Quote Originally Posted by defragster View Post
    Thats correct, but without LED and 1K Resistor:

    Partslist:
    •6 x SPI jedec Memory (e.g. 23LC1024 SOIC-8)
    •1 x 74LCX126MX SOIC-14
    •1 x 74LCX138MX SOIC-16
    •6 x Capacitor 0.1uF
    •3 x Resistor 10K

    IMPORTANT: This revision is NOT tested. I don't have it ! I ordered it yesterday, and i can say more in a few weeks.
    So, it's a bit risky to order it.

    Pls understand: in this untested state, I don't want that too many people buy it, really.
    I delete the link in a few hours.
    Last edited by Frank B; 08-10-2015 at 06:38 AM.

  21. #21
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,700
    I've started work on a delay object to support long delays with a single 23LC1024 chip and Frank's 6 chip Memoryboard.

    https://github.com/PaulStoffregen/Au...8486a1558fae21

    Functionally, this is meant to work just like the internal delay object, where the delay can be accessed with up to 8 taps.

    The object constructor allows you to specify which type of memory, and how much to use. If you omit the amount, by default it'll try to use the whole memory. Of course, the actual delays for each tap are specified when you activate each channel, so the amount of memory the object uses is the maximum possible delay.

    For example, if you have a 23LC1024 chip, which can provide 1458 ms of delay, you could create 2 delay object like this:

    Code:
    AudioEffectDelayExternal   dly1(AUDIO_MEMORY_23LC1024, 720);
    AudioEffectDelayExternal   dly2(AUDIO_MEMORY_23LC1024, 720);
    If you wanted to delay both channels of a stereo signal, you would create 2 objects which each allocate half the chip's memory. You can create any number of delay objects, each providing 8 configurable taps anywhere within their delay capability. Of course if you ask for more delay than the hardware can provide, it'll truncate your request to the maximum possible with the memory available.

    At least that how it's supposed to work. Right now, the code is doing a test using an array in internal RAM. The last part left to do is filling in the read(), write() and zero() functions for the actual hardware. I'm going to try doing the 23LC1024 soon. Later when Frank's board arrives, hopefully filling in those 3 functions for his hardware will be fairly simple.
    Last edited by PaulStoffregen; 08-10-2015 at 12:18 PM.

  22. #22
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,700
    Ok, I've added the 23LC1024 support code.

    https://github.com/PaulStoffregen/Audio

    Here's a simple test I've been using to output a couple waveforms....

    Click image for larger version. 

Name:	file2.png 
Views:	186 
Size:	62.1 KB 
ID:	4871 Click image for larger version. 

Name:	file1.png 
Views:	168 
Size:	74.0 KB 
ID:	4872

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    
    AudioSynthWaveformSine     sine;
    AudioEffectEnvelope        env;
    AudioEffectDelayExternal   dly1(AUDIO_MEMORY_23LC1024, 50);
    AudioEffectDelayExternal   dly2(AUDIO_MEMORY_23LC1024, 270);
    AudioMixer4                mix;
    AudioOutputI2S             headphones;
    
    AudioConnection            patchCord1(sine, env);
    AudioConnection            patchCord2(env, dly1);
    AudioConnection            patchCord3(env, dly2);
    AudioConnection            patchCord4(dly1, 0, mix, 0);
    AudioConnection            patchCord5(dly2, 0, mix, 1);
    AudioConnection            patchCord6(env, 0, headphones, 0);
    AudioConnection            patchCord7(mix, 0, headphones, 1);
    
    AudioControlSGTL5000 audioShield;
    
    // Use these with the audio adaptor board
    #define SDCARD_MOSI_PIN  7
    #define SDCARD_SCK_PIN   14
    
    void setup() {
            AudioMemory(10);
    
            SPI.setMOSI(SDCARD_MOSI_PIN);
            SPI.setSCK(SDCARD_SCK_PIN);
    
            audioShield.enable();
            audioShield.volume(0.7);
    
            sine.amplitude(0.9);
            sine.frequency(1200);
    
            dly1.delay(0, 0.5);
            dly2.delay(0, 122);
    }
    
    void loop() {
            env.noteOn();
            delay(50);
            env.noteOff();
            delay(250);
    
            Serial.print("loop ");
    
            Serial.println();
    
    }

  23. #23
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,700
    Here's another one, using the full 1.48 seconds of the 23LC1024 chip.

    Click image for larger version. 

Name:	file.png 
Views:	173 
Size:	43.1 KB 
ID:	4873

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    
    AudioSynthWaveformSine     sine;
    AudioEffectEnvelope        env;
    AudioEffectDelayExternal   dly;
    AudioOutputI2S             headphones;
    
    AudioConnection            patchCord1(sine, env);
    AudioConnection            patchCord2(env, dly);
    AudioConnection            patchCord6(env, 0, headphones, 0);
    AudioConnection            patchCord7(dly, 0, headphones, 1);
    
    AudioControlSGTL5000 audioShield;
    
    void setup() {
            AudioMemory(10);
            audioShield.enable();
            audioShield.volume(0.7);
            sine.amplitude(0.9);
            sine.frequency(800);
            dly.delay(0, 1500);
    }
    
    void loop() {
            env.noteOn();
            delay(100);
            env.noteOff();
            delay(12000);
    }

  24. #24
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,514
    Looks good !

    Maybe its worth to try SPI-DMA. I measured speed-improvements - mainly because interrupts can be processed parallel to the dma transfer. That was with larger blocks, >1K and with my audiocodecs, which spend long time in Interrupts.
    But it's helpful in every case i think, even if the profit is not so high.

  25. #25
    Senior Member
    Join Date
    Aug 2013
    Location
    Gothenburg, Sweden
    Posts
    292
    Impressive, love it .

    There seems to still be some missing code for address wrap around when the allocated memory is not the full chip.

    Do you have timings, home much time is consumed by the SPI ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •