Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Delay object and memory usage

  1. #1
    Senior Member
    Join Date
    May 2018
    Posts
    121

    Delay object and memory usage

    Hi!

    I have a questions about the memory consumption of the delay object:

    if I use only one tap with delay1.delay(); and use a relatively high value as delay time and then set it lower, will the memory consumption decrease accordingly or will it always stay at the highest used value?

    if so, is the only way to limit the storage size of the delay objects by using a fixed maximum delay time?

    And another question: what is the relationship between delay time and AudioMemory()?

    Thanks, Holger
    Last edited by C0d3man; 08-10-2020 at 10:51 AM.

  2. #2
    Senior Member houtson's Avatar
    Join Date
    Aug 2015
    Location
    Scotland
    Posts
    120
    Hi Holger

    if I use only one tap with delay1.delay(); and use a relatively high value as delay time and then set it lower, will the memory consumption decrease accordingly or will it always stay at the highest used value?
    memory consumption is decreased if you reduce the largest tap duration

    And another question: what is the relationship between delay time and AudioMemory()?
    You need to allocate memory with AudioMemory based on a number of blocks of samples. The default is 1 block is 128 samples (you can change this by setting AUDIO_BLOCK_SAMPLES). So if you have 1 second of delay and an AUDIO_BLOCK_SAMPLES of 128 you need to allocate at least (1.0*44100)/128 = 344 blocks - AudioMemory(344);. in practice and depending on what else you are doing, other audio objects will also use AudioMemory adding to the total needed.

    Easiest way to work with it is to print out AudioMemoryUsageMax() at an interval in your loop followed by AudioMemoryUsageMaxReset() - you should see it dynamically re-size as you change the delay tap time.

    Cheers, Paul

  3. #3
    Senior Member
    Join Date
    May 2018
    Posts
    121
    Hi Paul,

    thanks for your answer!

    Quote Originally Posted by houtson View Post
    You need to allocate memory with AudioMemory based on a number of blocks of samples. The default is 1 block is 128 samples (you can change this by setting AUDIO_BLOCK_SAMPLES). So if you have 1 second of delay and an AUDIO_BLOCK_SAMPLES of 128 you need to allocate at least (1.0*44100)/128 = 344 blocks - AudioMemory(344);. in practice and depending on what else you are doing, other audio objects will also use AudioMemory adding to the total needed.

    Easiest way to work with it is to print out AudioMemoryUsageMax() at an interval in your loop followed by AudioMemoryUsageMaxReset() - you should see it dynamically re-size as you change the delay tap time.

    Cheers, Paul
    Ok - good to know. My current problem: I am getting strange sounds when using higher values with the delay. And after reducing the delay time the problems still exist. Due to the very bis and complex code it seems that I really have to check the memory consumption with AudioMemoryUsageMax() and try to figure out how much AudioMem() I have to reserve and how much delay time is possible.

    I wonder if there is a way to calculate this at least for the teensy audio stack by knowing the number of blocks used for each object.

    Regards, Holger

  4. #4
    Senior Member houtson's Avatar
    Join Date
    Aug 2015
    Location
    Scotland
    Posts
    120
    I wonder if there is a way to calculate this at least for the teensy audio stack by knowing the number of blocks used for each object.
    I've only ever done it with trial and error and keeping an eye on AudioMemoryUsage(). The various objects use blocks up differently which I'm sure you know, delay uses blocks up quickly (obviously) but I'm not aware of a list of how much the others use.

    I did a quick check with a delay object setting the time to a long delay and a shorter one on a T4.0 - AudioMemoryUsage() definitely reports the usage as dynamic and reducing as delay time reduces. I don't know what else is going on in your code - are you using significant amounts of memory outside of the AudioMemory? Is it perhaps that the memory is being released back into the AudioMemory pool but not being made more generally available? Just guessing now I'm afraid - hope you get a fix

    Cheers, Paul

  5. #5
    Senior Member
    Join Date
    May 2018
    Posts
    121
    Quote Originally Posted by houtson View Post
    I've only ever done it with trial and error and keeping an eye on AudioMemoryUsage(). The various objects use blocks up differently which I'm sure you know, delay uses blocks up quickly (obviously) but I'm not aware of a list of how much the others use.

    I did a quick check with a delay object setting the time to a long delay and a shorter one on a T4.0 - AudioMemoryUsage() definitely reports the usage as dynamic and reducing as delay time reduces. I don't know what else is going on in your code - are you using significant amounts of memory outside of the AudioMemory? Is it perhaps that the memory is being released back into the AudioMemory pool but not being made more generally available? Just guessing now I'm afraid - hope you get a fix

    Cheers, Paul
    Ok, thanks! I think I have to try also until finding working setup. Yes, there is also much memory used outside the audio stack. But this memory is mainly staticly allocated. I think I have to try with divide and conquer until I have a running version.

    Regards, Holger

Posting Permissions

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