AUDIO(1)                                                 AUDIO(1)

     NAME
          mp3dec, mp3enc, oggdec, oggenc, flacdec, flacenc, sundec,
          wavdec, pcmconv, mixfs - decode and encode audio files

     SYNOPSIS
          audio/mp3dec [ -s seconds ] [ -d ]
          audio/oggdec [ -s seconds ]
          audio/flacdec [ -s seconds ]
          audio/wavdec [ -s seconds ]
          audio/sundec

          audio/oggenc
          audio/mp3enc [ -hprv ] [ -b bitrate ] [ -B bitrate ] [ -m
          mode ] [ -q q ] [ -s sfreq ] [ -V q ] [ long or silly
          options ]
          audio/flacenc [ -i fmt ] [ -l compresslevel ] [ -P padding ]
          [ -T field=value ]

          audio/pcmconv [ -i fmt ] [ -o fmt ] [ -l length ]

          audio/mixfs [ -D ] [ -s srvname ] [ -m mtpt ] [ /dev/audio ]

     DESCRIPTION
          These programs decode and encode various audio formats from
          and to 16-bit stereo PCM (little endian). The decoders read
          the compressed audio data from standard input and produce
          PCM on standard output at a sampling frequency of 44.1KHz.

          Mp3dec decodes MPEG audio (layer 1, 2 and 3). The -d option
          enables debug output to standard error.  Oggdec, flacdec,
          sunwdec and wavdec are like mp3dec but decode OGG Vorbis,
          FLAC lossless audio, Sun audio and RIFF wave.

        Decoding options
          -s seconds   seek to a specific position in seconds before
                       decoding.

          The encoders read PCM on standard input and produce
          compressed audio on standard output.

          Flacenc, oggenc and mp3enc produce FLAC, OGG Vorbis and MP3
          audio. For mp3enc, the MP3 file will use `constant bit-rate'
          (CBR) encoding by default, but that can be changed via --abr
          (average bitrate desired, ABR) or -v (variable bitrate,
          VBR).

          Oggenc accept raw PCM in the same byte order as /dev/audio
          (little-endian), while mp3enc -r expects big-endian.
          Flacenc by default expects raw PCM in the same format as
          /dev/audio, but also supports signed integer samples of bit
          widths 4 to 32, either little- or big-endian, one to eight
          channels and arbitrary samplerates, see -i option of
          pcmconv.

        Encoding options
          -b   set minimum allowed bitrate in Kb/s for VBR, default
               32Kb/s.  For CBR, set the exact bitrate in Kb/s, which
               defaults to 128Kb/s.
          -B   set maximum allowed bitrate in Kb/s for VBR, default
               256Kb/s.
          -h   same as `-q 2'.
          -m   mode may be (s)tereo, (j)oint, (f)orce or (m)ono
               (default j).  force forces mid/side stereo on all
               frames.
          -p   add CRC error protection (adds an additional 16 bits
               per frame to the stream).  This seems to break play-
               back.
          -q   sets output quality to q (see -V).
          -r   input is raw pcm
          -s   set sampling frequency of input file (in KHz) to sfreq,
               default is 44.1.
          -v   use variable bitrate (VBR) encoding
          -V   set quality setting for VBR to q. Default q is 4; 0
               produces highest-quality and largest files, and 9 pro-
               duces lowest-quality and smallest files.

        Long options
          --abr bitrate      sets average bitrate desired in Kb/s,
                             instead of setting quality, and generates
                             ABR encoding.
          --resample sfreq   set sampling frequency of output file (in
                             KHz) to sfreq, default is input sfreq.
          --mp3input input   is an MP3 file

        Silly options
          -f        same as `-q 7'.  Such a deal.
          -o        mark as non-original (i.e. do not set the original
                    bit)
          -c        mark as copyright
          -k        disable sfb=21 cutoff
          -e emp    de-emphasis n/5/c (default n)
          -d        allow channels to have different blocktypes
          -t        disable Xing VBR informational tag
          -a        autoconvert from stereo to mono file for mono
                    encoding
          -x        force byte-swapping of input (see dd(1) instead)
          -S        don't print progress report, VBR histograms
          --athonly only use the ATH for masking
          --nohist  disable VBR histogram display
          --voice   experimental voice mode

          Pcmconv is a helper program used to convert various PCM sam-
          ple formats. The -i and -o options specify the input and
          output format fmt of the conversion.  Fmt is a concatenated
          string of the following parts:

          s#   sample format is little-endian signed integer where #
               specifies the number of bits

          u#   unsigned little-endian integer format

          S#   signed big-endian integer format

          U#   unsigned big-endian integer format

          f#   floating point format where # has to be 32 or 64 for
               single- or double-precision

          a8   8-bit a-law format

          µ8   8-bit µ-law format

          c#   specifies the number of channels

          r#   gives the samplerate in Hz

          The program reads samples from standard input converting the
          data and writes the result to standard output until it
          reached end of file or, if -l was given, a number of length
          bytes have been consumed from input.

          Mixfs is a fileserver serving a single audio file which
          allows simultaneous playback of audio streams. When run, it
          binds over /dev/audio and mixes the audio samples that are
          written to it.  A service name srvname can be given with the
          -s option which gets posted to /srv.  By default, mixfs
          mounts itself on /mnt/mix and then binds /mnt/mix/audio and
          /mnt/mix/volume over /dev.  /dev/volume from the parent
          namespace is proxied with an additional control "mix" which
          is used to set the output volume of the mixer.  Another
          additional control "dev" can be used to switch between audio
          devices.  Mixfs will resample incoming audio to the format
          of the audio device output if it does not match the default
          (s16c2r44100).  An alternative mountpoint mtpt can be speci-
          fied with the -m option.  The -D option causes 9p debug mes-
          sages to be written to file-descriptor 2.

     EXAMPLE
          Play back an `.mp3'

               audio/mp3dec <foo.mp3 >/dev/audio

          Encode a `.wav' file as highest-quality MP3.

               audio/mp3enc -q 0 -b 320 <foo.wav >foo.mp3

          Create a fixed 128Kb/s MP3 file from a `.wav' file.

               audio/mp3enc -h <foo.wav >foo.mp3

          Streaming from stereo 44.1KHz raw PCM data, encoding mono at
          16KHz (you may not need dd):

               dd -conv swab | audio/mp3enc -a -r -m m --resample 16 -b 24

     SOURCE
          /sys/src/cmd/audio

     SEE ALSO
          play(1), zuke(1)
          http://www.underbit.com/products/mad/
          http://xiph.org/doc/
          http://flac.sourceforge.net/documentation.html

     HISTORY
          Pcmconv first appeared in 9front (December, 2012).  Mixfs
          first appeared in 9front (December, 2013).  Flacenc first
          appeared in 9front (January, 2021).


     REFORM(1)                                               REFORM(1)

     NAME
          audio, pm, shortcuts - MNT Reform 2 support utilities

     SYNOPSIS
          reform/audio [ -1 ] [ -D ] [ -m mountpoint ] [ -s service ]

          reform/pm [ -D ] [ -m mountpoint ] [ -s service ]

          reform/shortcuts [ -l light_step ] [ -v vol_step ]

     DESCRIPTION
          These programs provide support for certain functions of MNT
          Reform 2 computing device.  Some of them also make control-
          ling file systems available under /dev.

        Audio
          audio initializes the DAC (Digital-to-Analog Converter) on
          the platform and provides a standard audio(3) interface to
          control volume and other parameters.  With -1 only the ini-
          tialization is performed and the program exits immediately.

          The following files are provided by the program:

          audioctl
               Shows the current status (on or off ) of the three
               "outputs" - master, hp and spk.  Each can be enabled,
               disabled or toggled, by writing a single line to the
               same file, consisting of the output name and the
               desired action - on , off or toggle , accordingly.

               DAC can be reinitialized by writing a single reset.

          volume
               Provides an interface for volume control (see
               audio(3)).  For ease of use, volume supports relative
               adjustments by prefixing a number with a sign.  master
               +1, for example, will increase the volume on master by
               1%, which is 0.5dB for this particular output. For hp
               and spk one percent is 1dB.

               Enhanced stereo separation can be enabled by writing
               3d, followed by desired percentage of the effect.

        Power and monitoring
          pm presents a file system consisting of the following files:

          battery
               Returns attached battery array statistics in the same
               manner as acpi(8).

          cputemp
               Exposes the current temperature reading of the CPU.

          kbdoled
               An uncompressed Plan 9 image can be written to the file
               to display on the keyboard OLED.  Zero-length write
               clears the display.

          light
               Provides a way to control the backlight of the built-in
               LCD by writing lcd [-+]N, kbd [-+]N, or tb N N N N N,
               where N is expressed in percentage, either as an abso-
               lute value (0-100) or relative to the current bright-
               ness - by prefixing with a sign. For the trackball (tb)
               only 0 and 1 are valid values.  Reading light returns
               the current brightness.

          pmctl
               Reading pmctl gives the System Controller firmware ver-
               sion string, voltage (mV) of each cell and current(mA)
               of the battery array.

               Writing power off to pmctl will turn off all power
               rails, which is what fshalt(8) does after halting the
               file systems.

        Shortcuts
          shortcuts enables LCD brightness and audio volume adjustment
          via keyboard shortcuts.

          The program uses Rio's kbdtap to function:

               reform/shortcuts </dev/kbdtap >/dev/kbdtap

          Hyper+F1/F2 decreases/increases LCD brightness,
          Hyper+F7/F8/F9 skips to the previous track, (un)pauses or
          skips to the next track in zuke(1), Hyper+F10 (un)mutes the
          audio, Hyper+F11/F12 decreases/increases "mix" volume, or
          "master" if former isn't available.  Optionally, a single
          step amount can be set with -l for LCD light level (default
          is 5) and -v for volume (default is 3).  Values can be nega-
          tive to essentially swap the decrement and increment keys.

     SOURCE
          /sys/src/cmd/reform

     SEE ALSO
          audio(3)

     HISTORY
          MNT Reform 2 support first appeared in 9front (August,
          2022).

     BUGS
          Only 44100Hz (default) and 48000Hz sample rates are sup-
          ported with audio, recording is not implemented.

          Light was chosen as a shorter alternative to brightness.

          Current keyboard light level reading is only an indication,
          there is no way to get the actual value from the keyboard.

          Values displayed in the battery file are not precise, cell
          capacities are hardcoded in the System Controller firmware.



/plan9/man/1/