about.rst 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. About
  2. ========
  3. What does it do
  4. ---------------
  5. larigira integrates with MPD (Music Player Daemon) and prevents your playlist
  6. from running empty. It also has powerful support for "events": audio that must be played at some time.
  7. Features
  8. ---------
  9. * Simple to install
  10. * WebUI
  11. * modular event system
  12. Architecture
  13. -------------
  14. larigira delegates all the music playing business to MPD.
  15. It relies on ``tinydb`` as a db: it's actually just a json file, to achieve
  16. simplicity and flexibility. By default it is stored in ``~/.config/larigira/db.json``
  17. Code structure and core concepts
  18. -----------------------------------
  19. The code is heavily based on gevent: almost everything is a greenlet.
  20. alarm
  21. An alarm is a specification of timings. It is "something that can generate
  22. times". For example ``{ 'kind': 'single', 'timestamp': 1234567890 }``
  23. generates a single time (February 14, 2009 00:31:00), while
  24. ``{ 'kind': 'frequency', 'interval': 10, 'start': 1234567890 }`` generates
  25. infinite times, one every 10 seconds, starting from February 14, 2009
  26. 00:31:00.
  27. action
  28. An action is a specification of audio. It is "something that can generate a
  29. list of audio files".
  30. For example, ``{ 'kind': 'randomdir', 'paths': ['/my/dir', '/other/path'] }``
  31. will pick a random file from one of the two paths.
  32. Its main atribute is ``kind``. The kind essentialy specifies the function that will be run among a
  33. predefined set of :doc:`audiogenerators` . Every other attribute is an argument to the specified
  34. audiogenerator.
  35. event
  36. An event is an alarm plus a list of actions. At given times, do those things
  37. The main object is :class:`larigira.mpc.Controller`, which in turn uses :class:`larigira.mpc.Player` to control MPD. How does it know what to do? there are two main flows: the continous playlist filling and the alarm
  38. system.
  39. Continous playlist
  40. ~~~~~~~~~~~~~~~~~~
  41. :class:`larigira.mpc.Controller` has a "child" called :class:`larigira.mpc.MpcWatcher`. It watches for events on
  42. the playlist; when the playlist is changed it notifies Controller, which in turn will check if the playlist has
  43. enough songs. If that's the case, it will run an audiogenerator, and add the resulting audio at the bottom of the playlist.
  44. Alarm system
  45. ~~~~~~~~~~~~
  46. There is a DB. The lowest level is handled by TinyDB. :class:`larigira.event.EventModel` is a thin layer on
  47. it, providing more abstract functions.
  48. There is a :class:`Monitor <larigira.event.Monitor>`, which is something that, well, "monitors" the DB and
  49. schedule events appropriately. It will check alarms every ``EVENT_TICK_SECS`` seconds, or when larigira received
  50. a ``SIGALRM`` (so ``pkill -ALRM larigira`` might be useful for you).
  51. You can view scheduled events using the web interface, at ``/view/status/running``. Please note that you will
  52. only see *scheduled* events, which are events that will soon be added to playlist. That page will not give you
  53. information about events that will run in more than ``2 * EVENT_TICK_SECS`` seconds (by default, this amounts
  54. to 1 minute).