Teensy 3.2 complie error

Status
Not open for further replies.

pks8

Member
Hi all,

I am currently trying out pitch shifting code from another post in pjrc forum. Link : https://forum.pjrc.com/threads/46793-Anyone-Doing-Pitch-Shifting

But I always have some compile errors. Arduino version is 1.8.5 / Teensyduino version is 1.42-beta5.
The mod-delay.cpp and mod-delay.h I stored inside a folder called mod-delay at arduino library routine. I cannot understand the error message clearly.
Anyone can help me figure out what is wrong with my setup? Thank you!

The error message shown below:
compile error.PNG
 
It might need "#include <Arduino.h>" in that library file.

Verbose option might show more as indicated: in File / Preferences check Verbose on Compile.
 
It might need "#include <Arduino.h>" in that library file.

Verbose option might show more as indicated: in File / Preferences check Verbose on Compile.

Thanks for your suggestion! The code can be compiled successfully and uploaded to my teensy board after I added "#include <Arduino.h>" into the library file. However, the error message window will display "Low memory available, stability problems may occur", is this a serious problem?
 
"Low memory available, stability problems may occur", is this a serious problem?

It could be a problem. If your program uses many local variables, or uses malloc(), new or String (which internally uses malloc) to dynamically allocate RAM, all that usage will come from the remaining RAM which is not used for global/static variables.

In other words, it really depends on how your code (and the code in all libraries you use) is designed. We can't see any of your code. Arduino's console panel supports copy to clipboard, so you paste the exact message into your forum question very easily (no need to go to the trouble of a screenshot image).
 
It could result erratic or failing execution - depends on any dynamic memory use or other things in the program.
What are the values shown on these two lines at the tail of the compile?
Sketch uses 14672 bytes (1%) of program storage space. Maximum is 1048576 bytes.
Global variables use 5028 bytes (1%) of dynamic memory, leaving 257116 bytes for local variables. Maximum is 262144 bytes.

Following the link to other post it notes:: "// This is about max (97%!) for internal RAM"
If you are seeing that it may be fine if the code is running as posted.

The PJRC audio library now has pjrc.com info=AudioEffectDelay

It might be more efficient and more effective than that external library if it serves the same/needed purpose.

<EDIT> : Uncomment this at the end of loop() and it will show if the code needs as much as AudioMemory(100)
Code:
/*
    Serial.print("Diagnostics: ");
    Serial.print(" max, buffs: ");
    Serial.print(AudioProcessorUsageMax());
    Serial.print(" ");
    Serial.println(AudioMemoryUsageMax());
    AudioProcessorUsageMaxReset();
    xdly.inspect();
    */
 
@PaulStoffregen @defragster
Sorry for my obscure question. Since I still don't have too much experience on teensy and arduino, I just easily think that the code can be compiled and uploaded then everything is fine.

Following attached files are the code I am trying out.
View attachment pitch_shifting.inoView attachment mod-delay.cppView attachment mod-delay.h

The error message shown in the window after compilation :

Sketch uses 53032 bytes (20%) of program storage space. Maximum is 262144 bytes.
Global variables use 65056 bytes (99%) of dynamic memory, leaving 480 bytes for local variables. Maximum is 65536 bytes.
Low memory available, stability problems may occur.
 
That is really cutting it close. I saw the code in the linked post.

Paul or others can advise perhaps about the use of the now standard AUDIO lib delay.

One thing that might work to buy some ram:
Code:
int16_t ArbWave[256] = {…}
and 
int16_t DelayWave[256] = {…}

Could perhaps work as and give back 1K RAM:
Code:
const int16_t ArbWave[256] = {…}
and 
const int16_t DelayWave[256] = {…}
 
That is really cutting it close. I saw the code in the linked post.

Paul or others can advise perhaps about the use of the now standard AUDIO lib delay.

One thing that might work to buy some ram:
Code:
int16_t ArbWave[256] = {…}
and 
int16_t DelayWave[256] = {…}

Could perhaps work as and give back 1K RAM:
Code:
const int16_t ArbWave[256] = {…}
and 
const int16_t DelayWave[256] = {…}

Really appreciated for your kind reply, the code started working. Currently I am working on an engine sound project with teensy 3.2, I want to use pitch shifting to simulate the engine sound during acceleration. Engine sound is supposed to use the prerecorded audio file. I am quite confused whether I am on the correct trend, do you have any suggestion on this? Thank you!
 
Personally - no experience here - I can't say if the delay lib included or the PJRC Audio lib will be good for your purposes. There is plenty of room left for code on the T_3.2 - but RAM is beyond tight with the allocated dealy buffers. Did the code compile/work with the 'const' as indicated above? If I read the code right that will give back 1KB in RAM.

What is displayed for the uncommented code at the end of loop() - that might show some usable free RAM if requested audio memory could drop.

Are the 10 LED's and display present and in use?

If I did the math right there are 21504 bytes in the delay buffers. I'm not sure if the Audio Library version can provide similar or better delay in that same space. With the Audio shield you could perhaps add an SPI RAM chip that would give 128 KB of memory for delay through the PJRC lib?

Using a T_3.5 or T_3.6 would give more speed and much more RAM ( 256KB .vs. 64KB ) if the project needs to grow or larger delay buffer is needed that would be a better starting point.
 
Yikes, only 480 bytes left for local variables is very tight. Problems are very likely, unless all of your code is carefully crafted to use very few local variables.
 
OP - The code at the link in your first post does a fair amount of audio processing (filtering, etc) in addition to the basic tone shift function. Do you need all of it? Why not start with the basic tone shifting and slowly build up the functionality you need?
 
OP - The code at the link in your first post does a fair amount of audio processing (filtering, etc) in addition to the basic tone shift function. Do you need all of it? Why not start with the basic tone shifting and slowly build up the functionality you need?

Thanks for your reply. It took me quite a long time understand the code. Now I am trying to filter out the necessary functions.
 
Status
Not open for further replies.
Back
Top