Contrib

Post here your patches, tips, themes, scripts and so on.

Can't sort by track number?

Forums:

I just wanted to double check, you still can't sort a play list by track number right? If that's the case, I'd be interested in adding that feature - is there a standard for contributing, or do I just checkout the source and start hacking?

Script for alarm clock [Not working, need help]

Forums:

Hi,

First of all, the script I show you here is not working but I don't know if I'm doing something bad or I found a bug. This script is a part of a bigger script I'll use to transform my headless raspberry pi into a complete alarm clock. I used mocp during a week to test it without any problem (I usually use cmus but I need a music player that can run in background) but now that I want to make a script with it, it doesn't work. And I don't do anything more than usual. Once I met this bug, anything I do won't work anymore (this make me think it is a bug). I could reboot computer but uninstalling/reinstalling fix the bug and is faster.

The bug is "FATAL_ERROR: Can't receive value from the server!".

Here is the script :

#!/bin/bash
#===============================================================================
#
# FILE: alarm1.sh
#
# USAGE: ./alarm1.sh
#
# DESCRIPTION: Met de le musique de plus en plus fort pendant 2min30 puis l'éteint, attend 5 minutes et enfin la remet encore plus fort pendant 2 minutes. Pour l'éteindre, en plus du pkill, utiliser mocp -x.
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: Utilise mocp pour la musique. pkill mocp au départ du script.
# AUTHOR: AdrienHorgnies (), adrien.horgnies@gmail.com
# COMPANY: Louvain-li-Nux
# VERSION: 1.0
# CREATED: 09/03/2014 16:00:45 CET
# REVISION: ---
#===============================================================================

music=/home/horgnies/.clock/music

if [ $(ps -C mocp|wc -l) -eq 1 ];then
mocp --server #It clears the playlist so you do realize the alarm is ringing.
else
mocp --clear
fi

mocp --append $music #--on shuffle,repeat --volume 50
mocp --on shuffle,repeat
mocp --volume 50
mocp --next
mocp --play
#This try to make you start the day with a random song each time. It toggles next because otherwise it would always starts with first music of the directory. It sets repeat option so it still works with only one music in the directory.

sleep 30s
mocp --volume +10
sleep 60s
mocp --volume +20
sleep 60s
mocp --pause

sleep 5m
mocp --volume +10
sleep 150s
mocp --exit #surrend to wake up.

Earlier versions worked but I didn't think I would need a version manager for something that simple :-s.

I would be thankful if you can help me in any way,

LittleNooby

typing "shift + a" on ".." in file view adds files from current working directory

Forums:

Hi, I had a problem with my moc workflow:

* search for an artist/album with "/"
* tap "enter" to go inside
* go to parent dir <<<<---- this is the unwanted step
* tap "shift + a" to add files from the directory I was searching for

At first I wanted to make possible to add dir contets from "SEARCH" mode but the solution would be really twisted.
So I figured - why not add files from cwd when tapping "shift + a" on ".." file instead of showing "Can't add '..'"?
Here's the patch:

Index: interface.c
===================================================================
--- interface.c (revision 2586)
+++ interface.c (working copy)
@@ -1794,9 +1794,8 @@
}

if (!strcmp(file, "..")) {
- error ("Can't add '..'.");
free (file);
- return;
+ file = xstrdup(cwd);
}

iface_set_status ("Reading directories...");

ffmpeg plugin streaming and quvi URL parsing

Forums:

These two patches give moc the ability to play internet streams with the ffmpeg decoder plugin and the ability to automagically play URLs of the form http://www.youtube.com/watch?v=(id) (and anything libquvi understands).

ffmpeg_nopause.patch
quvi.patch

The quvi patch works only with quvi version 0.4.* (for now).

I might look into giving moc proper stream pausing at some point.

Native Opus decoder plugin (patch)

Forums:

Since r2482 MOC supports Opus decoding via FFmpeg/LibAV library. Some time ago I tried to implement native libopusfile decoder for MOC based on existing Vorbis decoder. To build it, you need libopus, libopusfile and libogg. The code includes contributions also by JCF and Gregory Maxwell from Xiph.org.

The code will probably be included in moc-2.6, but if someone wants to test it, I'm posting a patch now.

The patch should work either against moc-2.5.0-beta1 or current SVN code. After applying the patch you need to rerun "autoreconf" to update configure script.

If you combine this patch with Audio engine update (patch), Opus decoder will also support float decoding. Otherwise, standard fixed point decoder will be used.

Patch file: http://tomaszg.pl/moc/moc-2.5.0-beta1-opus.patch.gz (4kB)

Audio engine update (patch)

Forums:

I've been working on several optimalizations and fixes for MOC audio processing engine. I'm posting a patch against 2.5.0-beta1 version for anyone who would like to test/help/comment. The patch also includes some of "official" changes committed to SVN by JCF.

Changes:

  1. Support of more ALSA output sample formats. Until now MOC supported only S8,U8,S16,U16,FLOAT and S32,U32 (which were in fact 24bit data in 32bit samples). Now MOC supports also true S32 and U32, and 24-bit versions were renamed to S24,U24. Also S24_3 and U24_3 were added to support 24bit data in 3-byte samples (needed for exotic soundcards. please let me know if you need/use it).
  2. Added more detailed debug output of soundcard capabilities: Driver sfmt, Driver channels, Driver rate.
  3. Added config file option "MaskOutputFormats" to mask some output formats and removed "Allow24bitOutput". For example, to disable float, 24bit and 32bit formats set MaskOutputFormats = SFMT_FLOAT:SFMT_S32:SFMT_U32:SFMT_S24:SFMT_U24. Let me know if that it is useful to solve any problem.
  4. Added config file option "MaxChannels" to limit number of available channels.
  5. Added Dolby Prologic downmixing of 5.1 data down to 2.0. Support for more downmixing algorithms is possible in future.
  6. configure option --enable-internal-float which enables Vorbis float decoding which is the recommended way.
  7. Cleanup and removal of duplicate code, more debug messages in log.

The changes should be pretty transparent, only thing that needs to be changed is the removal of "Allow24bitOutput" option from config file.

Patch file: http://tomaszg.pl/moc/moc-2.5.0-beta1-sound.patch.gz (11kB)

[patch] Song ratings

Forums:

Hi all,

I've been using mocp for {4 years now, free}, and I think it's about time to give sth back to the community. So, I've tried to make moc capable of handling song ratings. Doing it right requires a few important decisions to be made; so far, I hacked together the smallest functionality that made sense to me. Ratings cannot (yet) be written to files, thus resolving the dilemma where to store them:)

Have a good one,
Adrian Lancucki

Patch (made against 2.5.0-beta1 revision 2526): http://pastebin.com/5J8LvY6J
Some eyecandy

Background

Different players handle ratings differently. They might either store the ratings in a local db (Amarok, iTunes, Banshee, Quodlibet), write it to audio files (Banshee, Windows Media Player) or pretend that they don't exist (foobar2000, Rhythmbox?, AIMP?).

Then there's the issue of how the ratings can be stored; AFAIK, some popular formats handle it differently:
- id3v1 - no ratings
- id3v2 - usually POPM frames indexed with e-mail/id (can be multiple per 1 file) with rating uint8 field 0-255, some players (foobar2k ratings plugin) use custom TXXX frames
- apev1/apev2 - no ratings
- vorbis comments - no official key for ratings, though some players (Banshee, Quodlibet) store something like "rating:quodlibet@foo.com=1.0" with ratings being 0.0-1.0 floats

Ratings patch

The good:
* it works:)
* ratings are stored in the cache

The bad:
* ratings are read-only
* they don't work with the ffmpeg plugin (I had a look at the sources and I'm pretty sure that libavformat can't handle POPM frames)
* the pretty star symbol I have used is utf8 and comes out garbled and breaks the layout on non-utf8 terminals
* ratings are not being stored in the playlist (.m3u doesn't handle ratings as #EXTINF)

I have patched the following plugins: aac, mp3, flac and vorbis. aac and mp3 both use libid3tag, so I'm using the first POPM frame available, mapping the values 0-255 to 0-5 stars the same way Banshee does
As for flac and vorbis, again similarly to Banshee, the pseudo-key "rating:banshee@foo=1.0" is being leveraged, mapping 0.0-1.0 to 0-255 (by multiplying by 255).

How to use it

1. Apply the patch.
2. Set "ShowRating = yes" in the config.
3. rm .moc/cache/tags.db
4. Make sure that ffmpeg is not the default plugin (by setting something like mp3(mp3):flac(flac):ogg(vorbis):" in the config file.

Having mocp store the ratings in db does a little sense to me, since it's not a portable solution. For now, I would suggest rating the songs elsewhere (Banshee or cmdline tools).

TODO
I'm not really sure how to check if the terminal supports utf8; if it's not, then the pretty star should be replaced with ugly "*".
Also, it would look nice if there was a new set of "theme" attributes for the rating stars only.
Make the ffmpeg plugin read the tags with libid3tag ?

TOO SMALL: How to **hack** moc to accept small screen size

Forums:

Hi all,

I love moc, but then I installed tmux and then the problems began; I wanted to have a small pane on the right size of the screen playing my favorite songs.

When I was hit with the message of **terminal too small** I was rather disappointed.

I begin installing and trying at least other 7 console music players, but none satisfied my fond for "JUST PLAY FROM FILES, YOU IDIOT PLAYER!!!!" instead of loading files into a playlist, DAH..!!!!

I then began ponder the idea to look at the source code and maybe trying to hack it. Well, I finally cracked it, and now I can set my pane size to 30 columns, instead 60.

OK here are the instructions: (obviously cannot guaranteed it will work perfectly, it is hacking for crist happy christmas sake;-)

0 - Tried on Ubuntu 12.04 Precise Pangolin

1 - Download 2.5.0-beta1 version.

2 - make sure you install the following libraries from your linux box (some libs maybe missing or a lib listed could be redundant):

libmad0-dev
libid3tag0-dev
zlib1g-dev
libsndfile1-dev
libflac-dev
libogg-dev
libsamplerate0-dev
speex
libspeex-dev
libmpcdec-dev
libsidplay2-dev
libsidutils-dev
libresid-builder-dev
libwavpack-dev
libtagc0-dev
libcurl4-gnutls-dev
libavcodec-dev
libavformat-dev
libltdl3-dev
libtool
libmodplug-dev
automake1.9
autoconf
libjack-dev
libasound2-dev
mpg123
mpg123-alsa
libmp3lame-dev
libmpg123-dev
libdb5.1
libdb1-compat
libdb5.1-dev
ffmpeg
moc-ffmpeg-plugin
musepack-tools
libvorbis-dev
vorbis-tools
libogg-dev
flac
libflac-dev
modplug-tools

3 - unpack the sources

4 - We only need to modify the file interface_elements.c

a. change the following line in check_term_size function:

mw->too_small = iw->too_small = COLS < 59 || LINES < 5;

with:

mw->too_small = iw->too_small = COLS < 30 || LINES < 5;

b. With your text editor find all instances of "COLS - 37" and COLS - 38". Now change the number to 27 and 28 respectively.

5. Now we are ready to go:
./configure
make
(sudo) make install (with root/administrative privileges)

6. Now you can run mocp.

We may run into some errors, like plugin not loaded or problems with alsa. These are all library related problems.

The installation will install files into:
/usr/local/bin (EXECUTABLE)
/usr/local/lib/moc (PLUGINS)
/usr/local/man/moc (MAN PAGE)
/usr/local/share/moc (THEMES)

Once you successfully compile moc and want to run into other computers, ensure you copy the folders above.

HAPPY HACKING

Milarepa

/.configure
make
(sudo) make install (with administrative/root privilegies)

Pages

Subscribe to RSS - Contrib