9

I want to have movie style sound effects in the terminal. You know, when every keystroke and line emits a cool little beep. (Something like this.) I've used KeyClick, but that's only for keyboard typing. I also want effects when characters are read across the screen, etc.

I know this is superflous as hell. And I'll probably get annoyed by it within five minutes. But it will be a glorious five minutes.

  • 4
    I don't have an answer for you, but your question mad me laugh. Thanks! – Chris Page Sep 18 '11 at 0:46
  • 3
    This doesn't do audio effects, but: you may find the Cathode terminal emulator's amazing visual effects amusing: secretgeometry.com/apps/cathode Perhaps you could suggest they add audio effects. It would be a good fit. – Chris Page Sep 18 '11 at 0:54
  • You can play a sound every line with bash's PROMPT_COMMAND, e.g. PROMPT_COMMAND="say 'something silly'" (replace say with command line audio playback of some samples). – Ingmar Hupp Sep 18 '11 at 1:56
  • Can't believe I've never seen Cathode before. What a wonderfully awesome yet 'useless' app! :) – chrismanderson Sep 20 '11 at 16:57
10
+50

Fun question :)

I'm not sure how you would get sound effects for everything but you could do something like this to get sound effects for a few things:

1) Open open your .profile (or .bashrc or wherever you like to keep your customizations) by opening a terminal window and typing:

open .profile

2) Add the following few lines to the bottom of the file:

function top() { afplay /System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/accessibility/Sticky\ Keys\ ON.aif; command top;}
function ls() { command ls; afplay /System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/accessibility/Slow\ Keys\,\ Key\ Registered.aif; }

3) Try typing 'ls' for a directory listing or 'top' to see the list of running processes & you'll get to hear the results of these commands.

By adding these two lines we are declaring two new functions with the same names as existing bash commands. We override the command itself so that we can play a bit of audio and then run the command itself (or vice versa as shown the 'top' example).

The audio files I am currently using are default audio files (at least on Lion) that are used for accessibility features. I chose these so that you could cut-paste, and see the trick in action but you could use any audio file in place of these.

Here's a site with a bunch of sci-fi sound effects you could use in place of these ones I'm borrowing from the OS:

http://fxhome.com/sounds/

  • 1
    On Snow Leopard, the path is /System/Library/Components/CoreAudio.component/Contents/Resources/SystemSounds/accessibility/. Nice find by the way; those are good sounds to use. I like the sound of Mouse Keys ON.aif for printing text to the screen. – styfle Sep 18 '11 at 6:32
  • Thanks for the info - it doesn't quite extend the sound to when characters are being drawn onto the screen, but that seems like it would require a whole different terminal environment, rather than just modding .profile. – chrismanderson Sep 20 '11 at 16:56
0

Not sure about the keystroke bit... but you could have it print the output of a terminal command like in the movies, i.e. each line is printed character by character and plays a little beep for each one. It looks cool initially and then gets really annoying. Would be fun to have a terminal that you could switch this on and off. Obviously pretty limited but could be a fun project to develop.

from subprocess import PIPE, Popen
import os

from time import *
import sys
from playsound import playsound

def print_immediately(string):
    sys.stdout.write(string)
    sys.stdout.flush()

def backspace():
    print('\r', end='')

def printline(x, silent=False):
    n = len(x)
    for i in range(n):
        print_immediately(x[:(i+1)])
        if not silent:
            beep()
        sleep(0.01)
        backspace()
    sys.stdout.write('\n')
    sys.stdout.flush()

def printlines(x, silent=False):
    result = str(x.decode("utf-8"))
    lines = str.split(result, "\n")
    for line in lines:
        printline(line, silent=False)

def beep():
    playsound('/Users/Blah/Projects/console/beep.wav', block=False)

def cmdline(command):
    process = Popen(
        args=command,
        stdout=PIPE,
        shell=True
    )
    return process.communicate()[0]

while True:
    command = input("user: ")
    if(command == 'exit'):
        break
    else:
        try:
            if command.find("cd ") != -1:
                dir = command.replace("cd ", "")
                os.chdir(os.path.expanduser(dir))
                print(dir)
            else:
                printlines(cmdline(command))
        except:
           print("Error!")

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .