Adding sound notifications for 'done compiling'

Having just read another topic on the long compilation times for ESP32(family) it popped into my mind that having sound notifications for 'done' compiling could be really helpful.

Compile times can be really long even on a fast processor, and if the time waiting could be spent more efficiently, more time would be left. Basically the Human should start multi-threading, but a sound notification can draw it back to the screen. It seems that it might not be to hard to add, but of course i don't know how much work this would be.

In the unfortunate circumstance that I have to compile code for the ESP32 I brew coffee; or is that multitasking? Some days I brew a lot of coffee.

A useful suggestion; you can suggest it on github: IDE 2.x / issues

Hi @Deva_Rishi. If you want to implement the feature yourself now, you can use the recipe.hooks.objcopy.postobjcopy.NUMBER.pattern post-build hook to invoke a command that produces a sound:

https://arduino.github.io/arduino-cli/latest/platform-specification/#pre-and-post-build-hooks-since-arduino-ide-165

In this case where you want to run the command regardless of which board is being compiled for, and it isn't in any way platform-specific, you can define it in the global platform.txt file, placed in the hardware subfolder of your sketchbook folder:

https://arduino.github.io/arduino-cli/dev/platform-specification/#global-platformtxt

I use a Python script as a tea timer. I didn't find an easy way to just produce a simple tone via my computer's audio output (yes I had all sorts of fun using BASIC to make interesting noises on the PC speaker of XT and 286 computers as a kid, but I need it to come through my headphones) so I instead play an audio file using this Python package:

For my application, I needed more than an audible notification alone, so this is why I used a Python script for the purpose. For your application, you might be better off to just use a simple command line tool that will play the audio, but I thought I'd mention the specific solution I found just in case it might be useful to you.

2 cups a day is where it stops, but i do play online speed chess sometimes, watch football or play Guitar or Flute.

Never really got around to that. Do remember a friend of mine came up with a floppy that had a song on it though. My ZX81 never had sound although the interface board should have been able to provide that as an option, but i only got that working just over 10 years ago.
I got Sennheiser BT headphones, and the BT only works on 1 side by now, so those i don't use.

Yeah probably. Thanks for all that. Don't have time to implement it yet, but as i thought the solution is simple enough.

Code that compiles on Arduino ide takes 60 seconds for an ESP32 and use around 60% of the memory, on my pc.

The same code for the same ESP32 with platformio takes 30 seconds.

Then the same code with Ubuntu and platformio takes 5 seconds.

Hmm just to get back on this. I found some time trying to implement it.
First of all on how to play a simple notification from the command line, and after some digging i found

powershell -c (New-Object Media.SoundPlayer "C:\Windows\Media\notify.wav").PlaySync();

does the trick, simple enough and expandable enough for me to work with.

Now i wanted to just play them for ESP32 compilations. Those can take such a long time that it would be nice to be reminded.

So where do i put :

recipe.hooks.objcopy.postobjcopy.NUMBER.pattern

and would it look like this fully completed ?

recipe.hooks.objcopy.postobjcopy.NUMBER.pattern=powershell -c (New-Object Media.SoundPlayer "C:\Windows\Media\notify.wav").PlaySync();

I tried adding it to the platform.txt of the installed core (in sketchbook) in particular (ESP32 2.0.11) because that file was modified from it's original already (i had to change the name to distinguish it in the IDE from it's newer version)

But then i got a closing " missing error on compilation.

I'm looking forward to you getting this fixed. I don't need a sound but a timestamp would be really useful and I could use the same mechanism. Often, I am disturbed while developing and don't then know, from the log output, how fresh the latest verify/upload is and all we get is something like this:

Linking everything together...
"C:\\Users\\6v6gt\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -Wall -Wextra -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F/oled_SSD1306_Test_V0_04.ino.elf" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F\\sketch\\oled_SSD1306_Test_V0_04.ino.cpp.o" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F\\libraries\\SPI\\SPI.cpp.o" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F\\libraries\\RF24\\RF24.cpp.o" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F\\libraries\\Wire\\Wire.cpp.o" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F\\libraries\\Wire\\utility\\twi.c.o" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F\\libraries\\Adafruit_GFX_Library\\Adafruit_GFX.cpp.o" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F\\libraries\\Adafruit_GFX_Library\\Adafruit_GrayOLED.cpp.o" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F\\libraries\\Adafruit_GFX_Library\\Adafruit_SPITFT.cpp.o" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F\\libraries\\Adafruit_GFX_Library\\glcdfont.c.o" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F\\libraries\\Adafruit_BusIO\\Adafruit_BusIO_Register.cpp.o" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F\\libraries\\Adafruit_BusIO\\Adafruit_I2CDevice.cpp.o" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F\\libraries\\Adafruit_BusIO\\Adafruit_SPIDevice.cpp.o" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F\\libraries\\Adafruit_SSD1306\\Adafruit_SSD1306.cpp.o" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F/..\\..\\cores\\arduino_avr_uno_83d732ec6bf56f7addb5051f4143e2d1\\core.a" "-LC:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F" -lm
"C:\\Users\\6v6gt\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F/oled_SSD1306_Test_V0_04.ino.elf" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F/oled_SSD1306_Test_V0_04.ino.eep"
"C:\\Users\\6v6gt\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F/oled_SSD1306_Test_V0_04.ino.elf" "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F/oled_SSD1306_Test_V0_04.ino.hex"
Using library SPI at version 1.0 in folder: C:\Users\6v6gt\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI 
Using library RF24 at version 1.4.2 in folder: C:\Users\6v6gt\Documents\Arduino\libraries\RF24 
Using library Wire at version 1.0 in folder: C:\Users\6v6gt\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire 
Using library Adafruit GFX Library at version 1.12.1 in folder: C:\Users\6v6gt\Documents\Arduino\libraries\Adafruit_GFX_Library 
Using library Adafruit BusIO at version 1.16.1 in folder: C:\Users\6v6gt\Documents\Arduino\libraries\Adafruit_BusIO 
Using library Adafruit SSD1306 at version 2.5.15 in folder: C:\Users\6v6gt\Documents\Arduino\libraries\Adafruit_SSD1306 
"C:\\Users\\6v6gt\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\6v6gt\\AppData\\Local\\arduino\\sketches\\3B7983AD63F5DC5770F3A618103FF08F/oled_SSD1306_Test_V0_04.ino.elf"
Sketch uses 19982 bytes (61%) of program storage space. Maximum is 32256 bytes.
Global variables use 881 bytes (43%) of dynamic memory, leaving 1167 bytes for local variables. Maximum is 2048 bytes.

Put this in platform.local.txt:

recipe.hooks.objcopy.postobjcopy.10.pattern.windows=powershell -c '(New-Object Media.SoundPlayer "C:\Windows\Media\notify.wav").PlaySync()'

There are already postobjcopy recipes number 1 to 3 so starting your own recipes at 10 leaves room for new ones from the vendor.

By putting your own additions and modifications in platform.local.txt and boards.local.txt you can leave the original files untouched.

My previous recommendation still stands:

I'll provide instructions you can follow to do that:

  1. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Take note of the path shown in the "Sketchbook location" field of the dialog.
  3. Click the "CANCEL" button.
    The "Preferences" dialog will close.
  4. Use your file manager (e.g., Windows "File Explorer") to create a folder named hardware under the folder at the path you saw in the "Sketchbook location" field of the "Preferences" dialog.
  5. Start any text editor.
  6. Create a new text file.
  7. Add the following content to the text file:
    # An arbitrary high index number is used to ensure the hook won't override one defined in the platform.
    recipe.hooks.objcopy.postobjcopy.99.pattern=date -Iseconds
    # The Windows `date` command only provides the date, so the Windows-specific `time` command is used if running on a
    # Windows machine.
    recipe.hooks.objcopy.postobjcopy.99.pattern.windows=cmd /C "time /t"
    
  8. Save the text file with the filename platform.txt inside the hardware folder you created at step 4.
  9. Select Tools > Reload Board Data from the Arduino IDE menus.
  10. Wait until you see a notification appear at the bottom right corner of the Arduino IDE window:

    Board data reloaded.

  11. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  12. Check the box next to "Show verbose output during: ☐ compile" in the "Preferences" dialog.
  13. Click the "OK" button.
    The "Preferences" dialog will close.

You will now see a timestamp printed in the Output panel at the end of the compilation process when you have the verbose compilation output preference enabled.

Oh alas it works !! Ah that makes me so happy. The reward for effort !!

Thank you so much.

Thanks very much. That, of course, worked fine.

I adapted it slightly with:

recipe.hooks.objcopy.postobjcopy.99.pattern.windows=powershell -c "$(Get-Date -UFormat '%A %d-%m-%Y %T')"

so the timestamp appears as below:

You are welcome. I'm glad the Arduino platform framework was able to accommodate your requirement.

I'm team ISO 8601, but that is certainly superior to the solution I provided!