Run Intervals? an Audio File Maker

by Mr_Glenn in Outside > Sports

978 Views, 2 Favorites, 0 Comments

Run Intervals? an Audio File Maker

P3010287.JPG

I initially tried running intervals using just a wrist watch, this was
not very accurate. Rather than buy a professional timer my solution was to write a small program to create sound files with timing beeps which I would listen and react to on my runs.

Parts:

PC or Laptop running Ubuntu.

The program & example interval routines:

Software Setup:

00 terminal.png

The file my_fitness_timer.c is just a plain text file which must be compiled into an executable format.

From terminal:

Run command: gcc –v

This will tell you if you already have the gcc compiler installed.

If not you will need to install it (You will need to be connected to the Internet for the next steps) :

Run command: sudo apt-get update

This will ensure that your machine is up to date.

Run command: sudo apt-get install gcc

This will install the compiler for the program.

You are now ready to compile the program (You don't need to be connected to the internet for this final step).

Run command: gcc –o my_fitness_timer my_fitness_timer.c –lm

This will compile the code from my_fitness_timer.c into an executable program called my_fitness_timer (the switch –lm links in the math modules which are required by the program.)

Note: for sudo you may need to enter your password.

Operation:

33 run.png

The program takes as its input a .txt file containing timing information and outputs an audio file (.wav) both are given to the program as command line arguments.

Example of how to run the program (from the terminal):

./my_fitness_timer tabata.txt tabata.wav

The program displays details of the times written to the sound file.

The Text Files Format and Making Your Own Files:

The routine timings are held in a simple text file using the following format:

Number of repeats, Frequency of beep (float), Beep time in 10th seconds (integer), Silence time in 10th seconds (integer),

(Where float is a floating point number e.g. 1000.0 and integer is a whole number e.g. 25)

Example:

60,1000.0,1,9,

This gives us 60 repeats of a tone of 1 KHz with an on time of 1 tenth second and silence for 9 tenth seconds.

File Conversion:

1 add.png
2 open.png
3 convert.png
set destination.png

My program produces .wav files as its output and these files are quite large, for example tabata.wav file runs in at 41.7Mb for a sound file of approximately 4 minutes. I normally convert them to .mp3 using VLC to do the conversion.

Start VLC

From the main menu:

Media -> Convert/Save...

Click the Add button

Select the file you wish to convert and click Open

Select convert from the drop down list Convert / Save

Select format you want to convert to; here MP3

Browse to the folder you want the .mp3 in, set a filename and click Save

Finally click Start and the conversion process will begin

Our tabata.wav has now been converted to tabata.mp3 and has a size of approximately 3.8 Mb.

Downloads

Notes:

This program has minimal error trapping.

I normally code in 15 seconds of preparation time before the routine starts and a longer high frequency beep to indicate the end of the session.

I normally use a high frequency to indicate the work periods and a low one to indicate the rest periods.

References:

Details of the makeup of a .wav file can be found at:

http://soundfile.sapp.org/doc/WaveFormat/

(Retrieved 20/May/2018)

Details of various high intensity interval routines:

https://en.wikipedia.org/wiki/High-intensity_interval_training

(Retrieved 20/May/2018)