Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding sound to a Fortran program

Tags:

fortran

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 ...

like image 977
Bo Sundman Avatar asked Oct 18 '22 18:10

Bo Sundman


2 Answers

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.

like image 189
Oo.oO Avatar answered Dec 15 '22 00:12

Oo.oO


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!).

like image 35
roygvib Avatar answered Dec 15 '22 00:12

roygvib