View on
Giulio Motta > Audio-Beep-0.11 > pods/jp/Beep.pod


Annotate this POD

View/Report Bugs

̾�� ^

Audio::Beep - ��Ũ����ˡ�ǡ������ԥ塼���η��󵡤��Ȥ��⥸�塼��

���� ^

    use Audio::Beep;

    beep($freq, $milliseconds);

    use Audio::Beep;

    my $beeper = Audio::Beep->new();
                # lilypond ���֥��å�ʸˡ���������������ޤ���
                # ����Ū�ʵ�ˡ���ǥե����ȤǤ���
                # (�����߼�����Ƥ��ޤ�)
    my $music = "g' f bes' c8 f d4 c8 f d4 bes c g f2";
                # ���ǥ��ȡ��ॽ�륰�������Ρ�Ÿ�����γ���

    $beeper->play( $music );

����ˡ ^

export �������ؿ�


Plays a customizable beep out of your computer beeper.


FREQUENCY is in Hz. Defaults to 440.

FREQUENCY �ϡ�Hz �ǡ��ǥե����Ȥϡ�440�Ǥ���

DURATION is in milliseconds. Defaults to 100.

DURATION �ϡ��ߥ��äǡ��ǥե����Ȥ�100�Ǥ���



Returns a new "beeper" object. Follows the available options for the new method to be passed in hash fashion.

������"beeper" ���֥������Ȥ��֤��ޤ��� new �᥽�åɤˤϡ������Υ��ץ����󤬥ϥå����Τ��������Ϥ����ޤ���

player => [player object | player module]

You can initialize your player object and then give it to the Audio::Beep object. Player objects come from Audio::Beep submodules (like Audio::Beep::Linux::beep).

���ե��֥������Ȥ��������Ǥ������줫�顢 Audio::Beep ���֥������Ȥˡ����ե��֥������Ȥ��Ϥ��ޤ��� ���ե��֥������Ȥ� Audio::Beep ���֥⥸�塼��(Audio::Beep::Linux::Beep�Τ褦��)�����⤿�餵���ޤ���

If you're lazy (as any good programmer should be) you can give a string as a player, like "Audio::Beep::Linux::PP" or even just "Linux::PP": the method will prepend the Audio::Beep namespace, require the module and call the new method on it for you. The new method will try to look up the best player on your platform if you don't specify one. So the following is all valid:

�⤷�����ʤ������Ƥʤ�(�ɤ��ʤ褤�ץ����ޤϤ��������٤��褦��)��player �Ȥ��ơ� "Audio::Beep::Linux::PP"����������"Linux::PP"�Τ褦��ʸ�����򤢤����뤳�Ȥ��Ǥ��ޤ�: �᥽�åɤ�"Audio::Beep"̾�����֤���Ƭ���դ��ä�(������prepend)���� ���Υ⥸�塼���� require ����new �᥽�åɤ򤽤ξ��ǸƤӽФ��ޤ���

    use Audio::Beep;
    #�ȤƤ����� (�̾���������Ȥ��Ԥ��٤��Ǥ�)
    my $beeper = Audio::Beep->new();
    my $beeper2 = Audio::Beep->new(player => 'Linux::PP');

    my $beeper3 = Audio::Beep->new(
        player  => 'Audio::Beep::Win32::API'

    require Audio::Beep::Linux::beep;
    my $beeper4 = Audio::Beep->new(
        player  => Audio::Beep::Linux::beep->new(
            path    =>  '/home/foo/bin/beep/'
rest => [ms]

Sets the rest in milliseconds between every sound played (and even pause). This is useful for users which computer beeper has problems and would just stick to the first sound played. For example on my PowerbookG3 i have to set this around 120 milliseconds. In that way i can still hear some music. Otherwise is just a long single beep.

���դ����륵������(�ȥݡ���)���Ȥˡ��ߥ��äεٷƤ򥻥åȤ��ޤ��� ���Τ��Ȥϡ������Τ��륳���ԥ塼���η��󵡤Υ桼�� - ���դ������ǽ��β����ͤ��ɤ��褦�� - �ˤȤäơ�ͭ�פǤ��� ���Ȥ��С����� PowerbookGC�� �ϡ�120�ߥ��ä������򥻥åȤ��ʤ����Фʤ��ޤ����� ���Τ褦�ˤ����С��ޤ������ڤ�ʹ�����Ȥ��Ǥ��ޤ��� �����ʤ��С�Ĺ��ñ���Υӡ��פˤʤ��ޤ���

$beeper->play( $music )

Plays the "music" written in $music. The accepted format is a subset of syntax. The string is a space separated list of notes to play. See the NOTATION section below for more info.

$music �ˤ����줿"����"�����դ��ޤ��� �����������ե����ޥåȤ� ��ʸˡ�Υ��֥��åȤǤ��� ʸ�����ϥ��ڡ�����ʬ�䤵�줿���դ��벻���Υꥹ�ȤǤ��� �ܤ����ϡ����Ҥε�ˡ�Υ����������򸫤Ʋ�������

$beeper->player( [player] )

Sets the player object that will be used to play your music. See the player option above at the new method for more info. With no parameter it just gives you back the current player.

���ڤ����դ����Τ˻Ȥä����ե��֥������Ȥ򥻥åȤ��ޤ��� �ܤ����ϡ����Ҥ�new�᥽�åɤ� player ���ץ������򸫤Ʋ������� �ѥ��᡼���򤢤����ʤ����С����ߤ� player ���ᤷ�ޤ���

$beeper->rest( [ms] )

Sets the extra rest between each note. See the rest option above at the new method for more info. With no parameter it gives you back the current rest.

���줾���β����δ֤����̤εٷƤ򥻥åȤ��ޤ��� �ܤ����ϡ����Ҥ�new�᥽�åɤ� rest ���ץ������򸫤Ʋ������� �ѥ��᡼���򤢤����ʤ����С����ߤ� rest ���ᤷ�ޤ���

��ˡ ^

The defaults at start are middle octave C and a quarter length. Standard notation is the relative notation. Here is an explanation from Lilypond documentation:

�ǽ��Υǥե����Ȥϡ����֤Υ��������֤Υɤǡ�1/4Ĺ�Ǥ��� ɸ���ε�ˡ������Ū�ʵ�ˡ�Ǥ���Lilypond �ɥ��������Ȥˤ��������Ǥ���

    If no octave changing marks are used, the basic interval between 
    this and the last note is always taken to be a fourth or less 
    (This distance is determined without regarding alterations; 
    a fisis following a ceses will be put above the ceses)

    a fisis following a ceses will be put above the ceses)

    The octave changing marks ' and , can be added to raise or lower 
    the pitch by an extra octave.

    ���������֤��ѹ������ޡ����� ' �ǡ����̤ʥ��������֤ǥԥå��򤢤����겼������

You can switch from relative to non relative notation (in which you specify for every note the octave) using the \norel and \rel commands (see below)

\norel�ȡ�\rel ���ޥ���(����)���Ȥäơ����Ф������ФǤʤ���ˡ�˥����å��Ǥ��ޤ� (���䤴�Ȥ˥��������֤����ꤷ�ޤ�)��


Every note has the following structure:




NB: previous note duration is used if omitted. "Flatness", "Sharpness" and "Dottiness" are reset after each note.

���ա���ά�����������β����λ�³���֤��Ȥ����ޤ��� "Flatness"�ȡ�"Sharpness"�ȡ�"Dottiness" �ϡ����䤴�Ȥ˥ꥻ�åȤ����ޤ���


A note can be any of [c d e f g a b] or [r] for rest.

������[c d e f g a b] ����������[r] �Τɤ줫�Ǥ���

flat or sharp

A sharp note is produced postponing a "is" to the note itself (like "cis" for a C#).

���㡼�פβ����ϡ�"is"�������θ����֤����Ȥǡ������ޤ��� (C#�Τ����ˡ�"cis"�Τ褦�ˤ��ޤ�)

A flat note is produced adding a "es" or "s" (so "aes" and "as" are both an A flat).

�ե��åȤβ����ϡ�"es"����"s"�������θ����֤����Ȥǡ������ޤ��� ("aes"�ȡ�"as"�ϡ��ɤ�����A�ե��åȤǤ�)


A ' (apostrophe) raise one octave, while a , (comma) lower it.

'(���ݥ��ȥ��ե�) �ϡ����������֤��ҤȤĤ����ޤ��� ������,(������)�ϡ����������֤��ҤȤIJ����ޤ���


A duration is expressed with a number. A 4 is a beat, a 1 is a whole 4/4 measure. Higher the number, shorter the note.

duration �ϡ�������ɽ���ޤ��� 4 �ϡ��ӡ��Ȥǡ�1 �ϡ��ޤä���4/4��Ĺ���Ǥ��� �������⤱���й⤤�ۤɡ�������û���ʤ��ޤ���


You can add dots after the duration number to add half its length. So a4. is an A note long 1/4 + 1/8 and gis2.. is a G# long 7/8 (1/2 + 1/4 + 1/8)

duration�ο����θ��ˡ��ɥåȤ��ä��뤳�Ȥ��Ǥ�������Ĺ����Ⱦʬ���ä��뤳�Ȥ��Ǥ��ޤ��� a4. �Ǥ����顢���� 1/4 + 1/8 ��Ĺ���β����Ǥ�����gis2 �ϡ���# 8/7(1/2 + 1/4 + 1/8)��Ĺ���Ǥ���

�õ�: "r"

A r note means a rest. You can still use duration and dots parameters.

r �����ϡ���������̣���ޤ���duration �ȡ�dots �Υѥ��᥿���Ȥ����Ȥ��Ǥ��ޤ���


Special commands always begin with a "\". They change the behavior of the parser or the music played. Unlike in the Lilypond original syntax, these commands are embedded between notes so they have a slightly different syntax.

���̤ʥ��ޥ��ɤϾ��ˡ�"\" �ǻϤޤ��ޤ��� �ѡ����������դ����벻�ڤο����񤤤��ѹ����ޤ���Lilypond�Υ��ꥸ�ʥ���ʸˡ�Ȥϰ��äơ� �������Υ��ޥ��ɤϲ����δ֤��������ޤ��ޤ��������ǡ��������ä�ʸˡ�ˤʤäƤ��ޤ���


You can use this option to change the tempo of the music. The only parameter you can use is a number following the bpm string (like "bpm144"). BPM stands for Beats Per Minute. The default is 120 BPM. You can also invoke this command as \tempo

���Υ��ץ��������Ȥäơ����ڤΥƥ��ݤ��ѹ��Ǥ��ޤ��� �Ȥ��ѥ��᥿�ϡ�bpm�θ��˿�����³��ʸ�����Ǥ�("bpm144"�Τ褦��)�� BPM �ϡ�Beats Per Minute ����̣���ޤ����ǥե����Ȥ� 120 BPM �Ǥ��� \tempo �Τ褦�ʥ��ޥ��ɤǡ��ƤӽФ����Ȥ��Ǥ��ޤ���


Switches the relative mode off. From here afterward you have to always specify the octave where the note is.

���Х⡼�ɤ򥪥դˤ��륹���å��Ǥ��� �����������ϡ����Ĥ⡢���䤬���������Υ��������֤����ꤹ��ɬ�פ������ޤ���


Switches the relative mode on. This is the default.



You can transpose all your music up or down some octave. ' (apostrophe) raise octave. , (comma) lowers it. This has effect just if you are in non-relative mode.

���Ƥβ��ڤΥ��������֤򤤤��Ĥ��夲�뤫�����뤫�֤������ޤ��� '(���ݥ��ȥ��ե�)�ϥ��������֤��夲�ޤ���,(comma)�ϥ��������֤򲼤��ޤ��� ���Х⡼�ɤǤʤ��⡼�ɤǤ����������ϸ��̤������ޤ���


You can embed comments in your music the Perl way. Everything after a # will be ignored until end of file

���ڤ�Perl����ˡ�ǥ������Ȥ����������ޤ��� �ե������κǸ��ޤǡ�#�θ������ƤΤ��Τ�̵�뤵���ޤ���


    my $scale = <<'EOS';
    \rel \bpm144
    c d e f g a b c2. r4    # a scale going up
    c b a g f e d c1        # and then down

    my $music = <<'EOM'; # a Smashing Pumpkins tune
    \bpm90 \norel \transpose''
        d8 a, e a, d a, fis16 d a,8
        d  a, e a, d a, fis16 d a,8

    my $love_will_tear_us_apart = <<'EOLOVE'; # a happier tune
        e1      fis4 g8 fis4 e8 d4
        b2.. d8 a2..            d8
        e1      fis4 g8 fis4 e8 d4
        b2.. d8 a1

There should be extra examples in the "music" directory of this tarball.


�� ^

 perl -MAudio::Beep -ne 'print and beep(550, 1000) if /ERROR/i' logfile

 # PC���ۥեޥ��⡼�ɤˤ��� (courtesy of Thomas Klausner)
 perl -MAudio::Beep -e 'beep(21 + rand 1000, rand 300) while 1'

 perl -mAudio::Beep -0777e 'Audio::Beep->new->play(<>)' musicfile

ɬ�׾��� ^


Requires either the "beep" program by Johnathan Nightingale (you should find sources in this tarball) SUID root or you to be root (that's because we need writing access to the /dev/console device). If you don't have the "beep" program this library will also assume some kernel constants which may vary from kernel to kernel (or not, i'm no kernel expert). Anyway this was tested on a 2.4.20 kernel compiled for i386. With the same kernel i have problems on my PowerBook G3 (it plays a continous single beep). See the rest method if you'd like to play something anyway.

Johnathan Nightingale �ˤ��롢"beep"�ץ����� (tarball�Υ������Ǹ��Ĥ����Ϥ��Ǥ�)��ɬ�פȤ��ޤ��� root��SUID���뤫��root�ˤʤ�ɬ�פ������ޤ� (/dev/console�ǥХ����˽񤭹��ߥ�����������ɬ�פ����뤫���Ǥ�)�� "beep"�ץ����ब�ʤ����С����Υ饤�֥����ϡ� kernel����kernel���Ѥ��뤤���Ĥ���kernel���������ꤷ�ޤ� (�㤦���⤷���ʤ�������kernel�������ѡ��ȤǤϤʤ��Τ�)�� �Ȥˤ��������Υ⥸�塼���ϡ�i386�Ѥ˥����ѥ��뤵�줿2.4.20 kernel �ǥƥ��Ȥ����Ƥ��ޤ��� Ʊ��kernel�ǻ���PowerBook G3�����꤬�����ޤ�(ñ����beep��Ϣ³���Ʊ��դ��ޤ�)�� �Ȥˤ��������������դ����������ϡ�rest�᥽�åɤ򸫤Ʋ�������


Requires Windows NT, 2000 or XP and the Win32::API module. You can find sources on CPAN. Some PPM precompiled packages are at No support is available for Windows 95, 98 and ME yet: that would require some assembler and an XS module.

Windows NT �� 2000 �� XP �ȡ�Win32::API�⥸�塼����ɬ�פȤ��ޤ��� CPAN�ǥ����������դ��뤳�Ȥ��Ǥ��ޤ��� �ץꥳ���ѥ��뤵�줿�ѥå������� �ˤ����ޤ��� Window 95, 98, ME �ϡ��ޤ������ݡ��Ȥ��Ƥ��ޤ���: �����ϥ������֥��ȡ�XS�⥸�塼����ɬ�פȤ��ޤ���

�Хå������� ^

If you are a developer interested in having Audio::Beep working on your platform, you should think about writing a backend module. A backend module for Beep should offer just a couple of methods:

Audio::Beep����ʬ�Υץ��åȥե�������ư�������Τ˴ؿ��Τ��볫ȯ�Ԥʤ顢 �Хå������ɥ⥸�塼�����񤯤��ȤˤĤ��ƹͤ����٤��Ǥ��� Beep�Τ����Ρ��Хå������ɥ⥸�塼����1�ȤΥ᥽�åɤ��󶡤��٤��Ǥ�:

NB: FREQUENCY is in Hertz. DURATION in milliseconds

����:FREQUENCY �ϡ��إ��ĤǤ��ꡢDURATION�ϡ��ߥ��äǤ���


This is kinda obvious. Take in the options you like. Keep the hash fashion for parameters, thanks.

�����Ϥ������ټ����Ǥ��������ߤʤ饪�ץ������������Ʋ������� �ѥ��᡼���ϥϥå����η����Ǥ�����������


Plays a single sound.



Rests a DURATION amount of time



This module works for me, but if someone wants to help here is some cool stuff to do:

���Υ⥸�塼���ϡ����Τ�����Ư���ޤ����Ǥ�������Ƥ��������ʤ顢 �����٤���cool stuff �������ޤ�:

- an XS backend

- an XS Windoze backend (look at the Prima project for some useful code)

- some work is needed on Windows Makefile part

�Х� ^


��� ^


Copyright 2003 Giulio Motta <>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

�����ˤĤ��� ^

�����ԡ���ƣ�� (

Perl�ɥ������������ܸ��� Project �ˤơ� Perl�⥸�塼�롢�ɥ��������Ȥ��������ԤäƤ����ޤ���
syntax highlighting: