5

I have a rather dull Fortran program that are used by students for some heavy calculations and I thought the program might be a little more interesting if I could add some sounds here and there. Is there any utility to generate sounds that is callable from a Fortran program? I would like to call a routine with for example a selection of MP3 files.
I do not like programs which beeps and plings in general but this is a kind of last resort to keep the students alert ...

Bo Sundman
  • 424
  • 3
  • 13
  • What operating system? – John Coleman Jan 08 '16 at 18:19
  • The program is used both on WIndows and Linux – Bo Sundman Jan 08 '16 at 18:54
  • 2
    Perhaps you could insert some (probably quite a lot of) file reading and writing statements. Get the speed and rhythm right and it would sound like a DJ scratching. I guess you'd need two disks for this to work well. – High Performance Mark Jan 08 '16 at 20:19
  • @HighPerformanceMark I bet you could also do nice stuff with the CPU fans if you time your calculations right. If all fails, you could use a paper clip to enhance the experience ;-) – Alexander Vogt Jan 09 '16 at 11:37
  • I am old enough to have used a BESK computer with a some 10000 minature electron valves (before integrated circiuts existed) and I remember it used to generate different sounds when the iterations were converging or diverging. – Bo Sundman Jan 09 '16 at 21:20
  • @HighPerformanceMark: Are you suggesting something like this? https://www.youtube.com/watch?v=cM_sAxrAu7Q – jvriesem Apr 30 '18 at 06:50

2 Answers2

2

I'd go with C library (e.g. How to play MP3 files in C?).

I'd create shared lib with your routine (e.g. code playing some sort of mp3 list) and called it from Fortran code.

Question is, whether this is what you are looking for.

Community
  • 1
  • 1
Oo.oO
  • 12,464
  • 3
  • 23
  • 45
1

It may be interesting to try the system call together with a command-line tool, e.g.

program main
    implicit none
    integer i
    character(100) :: message(3)

    message(1) = "hi"
    message(2) = "yo"
    message(3) = "done!"

    do i = 1, 3
        call system( "say " // trim( message(i) ) )
    enddo
end

which says any message via speech synthesis on Mac OSX. A similar thing may be achieved for MP3 files with some audio commands (on Windows, Mac, and Linux). This demo seems to be using such an approach (Note: music starts from the page!).

Community
  • 1
  • 1
roygvib
  • 7,218
  • 2
  • 19
  • 36