9vorbis -- an OGG-Vorbis player for Plan9 including a user-interface and semi-advanced playlist support


hai2u,

An ethical note:
I use vorbisfile.a and thus depend on APE. I don't have time to fork lib9xiph (or write patches Xiph can put in), neither do I have a strong heart to read libogg/libvorbis and write a decoder which works without ANSI-code in the library. 



Dependencies:
libvorbis and libogg. See '9OGG-Vorbis'.


Building from source:
% mk
should do the trick. 
% mk install
copies 9vorbis to $home/bin/$objtype.



Invokation:
9vorbis accepts commands on stdin and argv, so these two are identical:
% 9vorbis bl0b.ogg play
% echo bl0b.ogg >bl0b.pls ; echo play >> bl0b.pls ; 9vorbis 
9vorbis> open bl0b.pls

(Note that with stdin, a blank seperates commands...)

% 9vorbis <bl0b.pls
does not work. The EOF makes a loop go wild, I have no idea how to fix that properly.
I would love that, tho - so if you can enlight me, do it!
To achieve what you probably intended with that (load a data-file on-load), you
can do:
% 9vorbis 'open bl0b.pls'


Audio(3):
9vorbis uses audio(3)s /dev/audio and /dev/volume for its operation, so you must
have #A in your namespace, so bind it before invoking 9vorbis:
% bind -a '#A' /dev
% 9vorbis [...]
There is no way to do that after 9vorbis has been started. Trust me on that.


Commands are:
play				-- start playback
pause			-- stop playback-thread
stop				-- kill playback-thread
shuffle			-- switch on shuffle (shuffle also is repeat - nobody knows when to stop)
repeat			-- switch on repeat
announce			-- switch off anouncements
np				-- printf what song is currently played
skip N			-- fast forward/backward N seconds
next				-- skips current track (if playback is paused or stopped, next restarts playback)
prev				-- steps back to previous track (if playback is paused or stopped, prev restarts playback)
wbnext			--WouldBenext - show what track comes next
jump N			--jump to track-nr. N
clear [/regexp/]	-- clear playlist (optionally clear only files matching regexp. note: If you want to match on Vorbis-comments, use clear -vc /regexp/ ; use -n to NOT your selection)
pls [...]			--Prints current playlist. Supports -n and -vc, too
exit | quit			-- exit 9vorbis normally. Child is killed.
abort			-- exit 9vorbis without taking care. See the Abort-section below.
vol N			-- Sets the output volume to N (n > -1 < 101)
bl0b.ogg			-- put bl0b.ogg into the playlist.
dump [filename]	-- dump current playlist to filename (default: $home/dump.pls)
open [filename]	-- opens commandset from filename (default: $home/dump.pls)
help				-- a help screen


Notes
-----

# is a comment. 

9vorbis>
There is another command, but it is special. It is the '9vorbis> '-command. It executes
the command in its parameter-list. The overall sense of this is that you can select 
commands that you have already entered and simply 'execute' (in acme) || 'Send' (in rio-windows)
them. There is no direct limit in recursion, but the buffer holding commands is just 4kb huge.
Note that, depending on your font, the 'l' of 9vorbis is very small - take care to select that, too :P

Having mentioned that, as you have probably guessed now, 9vorbis> is the command prompt:
If you see that, you are talking to 9vorbis, and all the commands proposed above apply. Sub-functions
*may* ask you stuff, but normally communication is expected to be done via parameters, and
only parameters to the functions - missing parameters is by convention an error.

!
There is yet another command, it exec()s its parameters. Note that:
9vorbis> !ls files/*
9vorbis> ls: files/*: 'files/*' does not exist <-- will not work. rc(1) does globbing, 9vorbis does not.
This one will work.
9vorbis> !ls files
9vorbis> files/04_bzzt!.ogg
files/05_fiction_dreams_in_digital.ogg
files/1.ogg
files/2.ogg
files/3.ogg
files/nexus6-ab_chic.ogg

As you can see, the parent (9vorbis) prints his prompt right before the child gets the chance
to print something out. That is no problem, see the 9vorbis> command section above. You
can just mark, snarf, and paste that into 9vorbis.
Also note things like | (piping) will not work, either.
Because of an implementational issue, this does not work:
9vorbis> !rc -c 'ls files/* | grep foo.ogg'
because the code does not know about quoting, either. Write me an email, bitch about it,
maybe I can be made into supporting that.



Using acme:
You may use acme to navigate to your music, select, snarf, then paste the filelist into 9vorbis. 
However note that the working directory of 9vorbis may (or, more certainly will) differ. 
As acme uses tabs, an Edit will only make it work if the window is that small that acme does
a line-break for every file. In the end, 9vorbis is rather made for win. (It depends on it).


Manipulating the playlist:
As you may have noticed, there is no command to move entries arround in the playlist. 
This has intentionally left out because Acme and Rio allow us to change text - so here is
how it is done. Suppose you have three files in your playlist, you want to delete the last
one and move #2 to #1.
9vorbis> pls
#  [1] 5F-X - Bzzt!
files/04_bzzt!.ogg
#  [2]
files/05_fiction_dreams_in_digital.ogg
#  [3]		[]
files/1.ogg
9vorbis> clear 1.ogg
9vorbis> 

Now use your mouse to move #2 (the fiction-song) before Bzzt!, mark, snarf, paste.
It is save to mark the track-number, playmode and vorbis-comment because all
these information are prefixed by a comment-char (#), which makes 9vorbis ignore
that line.



File-name completition:
It works. At least I know it works in acme. just start by something, e.g. /usr/glenda/,
then press Ctrl+f.


clear:
There are several things you have to know about the clear-command when it comes
to pattern-matching, NOTing and using Vorbis-comments. In all cases, we are doing
our work in a loop, and the code has no idea about the greater context - that means,
the code which frees the playlist-structures for example does not know if it has freed
everything. Here is an example:
9vorbis> clear ogg
9vorbis> pls
Ls-dj: shuffle: on; repeat: off; announcements: on
Playmode: stopped
9vorbis> 
Despite the fact that clearing all files which match /ogg/ in the filename is, from the
logical point of view, equal to 'clear', but idiotic nevertheless, the code does not know 
that it freed all - thus the pointers are broken. I have seen that playvorbis() actually 
still got new files from plsgetnext(), which probably is because there is a pointer
to the currently played entry in Ls-dj, and if you switch shuffle off, the code does 
not need a global entry-point for the playlist (but pls needs, so it things the playlist is empty).
Your only way to get out of this is to 'clear' (without arguments) as it knows that it frees
everything and thus creates a new, empty playlist) or quit.
If you intend to delete all songs but the ones containing 'Bzzt' in a Vorbis-comment field,
note that the code uses the filename of a song if there is no Artist-field in the comments 
(elsewise, it would have skipped that file completely, so that is all what I can do for you), 
which will make clear -n -vc behave as suggested by pls -n -vc in 99 per cent of the cases.


Abort:
The code may fork new proccesses. This playlist will not do what you wanted it to do:
bl0b.ogg
play
exit

As bl0b.ogg is added to the playlist, then played, then exit is found, parsed, and 9vorbis
quits. That is why abort is there. You still loose control about it - especially bad if you
want to skip some seconds, change the volume, etc.
Also note that because of the same reason, you cannot normalize your songs by doing:
volume 90
bl0b-loud.ogg
play
volume 100
bl0b-normal.ogg

.... I guess you got the picture.


All the code is released under the terms of the MITL:
Copyright (c) 2006 Sascha Retzki.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.



Have phun, lantis
