Using xhippo as an mp3 or wav media file RECORDER

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

Using xhippo as an mp3 or wav media file RECORDER

#1 Post by mcewanw »

This howto shows how to use it as a tiny, very low resource usage, mp3 or wav recorder assuming you have arecord and lame also installed.

xhippo is usually used to play media files (audio and/or video) via commandline backend programs such as mpg123 or madplay or mplayer. However, I have previously shown how to use it to play mp3 files using only lame and aplay via a shell script here:

http://www.murga-linux.com/puppy/viewto ... 534#708534

I provided a dotpet gtk2 version of xhippo, which included that mp3 playback capability here:

http://www.murga-linux.com/puppy/viewtopic.php?t=86753


xhippo can more generally, however, using the above technique, be used to control any running process (or pipe of running processes) via a shell script. This howto is an exemplar of that, in which xhippo is used to create a media recorder.

Steps:

1. Download the attached tiny shell scripts xhippo_record_mp3 and xhippo_record_wav to /usr/bin and make them executable. (Note that all the attached files are provided in tar.gz format since the murga forum doesn't accept raw files).

2. Replace your existing xhippo configuration file, xhippo.config, with the attached one. Note that in the xhippo dotpet I provided in other thread, xhippo.config is stored in the default location /usr/local/etc. Alternatively, if you have made alterations of your own to xhippo.conf and want to keep them, simply insert the following two lines into your xhippo.config:

Code: Select all

type:mp3#:xhippo_record_mp3:g
type:wav#:xhippo_record_wav:g
Note that this alteration associates two new file extensions, mp3# and wav#, with the scripts xhippo_record_mp3 and xhippo_record_wav respectively. Note that I chose to add the hash to the end of mp3 and wav as a simple way of creating a unique, relevantly named new file extension, but I could have used any unique extension name in practice for this purpose.

How to record in xhippo

Using xhippo to now record media files is a bit unusual since the mechanism for telling xhippo the filename to process is generally to drag and drop the file onto the xhippo window. That is the same mechanism required here:

1. Make sure your alsa is working and configured for recording, which is briefly discussed in the Precord post:

http://www.murga-linux.com/puppy/viewto ... 349#370498

2. In your favourite filemanager, create an empty file of the form anyname.mp3# (note the # is essential in the extension to inform xhippo you want to record and mp3 (for wav recording name the file in the form anyname.wav#).

3. Drag the empty anyname.mp3# (or anyname.wav#) file from your filemanager onto the xhippo window and click on it there and recording will begin. That's all there is to it... You can start, pause and stop the recording using the xhippo controls. Note that the original .mp3# or .wav# file extension will be replaced with the relevant .mp3 or .wav filename in the recorded filename (i.e. the # in the original filename will be automatically removed).

4. Both scripts xhippo_record_mp3 and xhippo_record_wav come with default quality settings (for example bitrate and mode mono/stereo), with hints in these scripts on what these can be changed to. These settings, and the commandline were stolen from the code used in Precord. They are all at the top of the extremely short scripts. Feel free to change these quality settings using your favourite text editor (the current scripts are simple; no fancy wizard provided, sorry).

5. Making timestamped recordings: nstead of creating files of the form anyname.mp3# or anyname.wav#, you can use the special filename date.mp3# (or date.wav#). Then the final recording will be automatically renamed in the form "timestamp.mp3" or "timestamp.wav", where timestamp will be the time (year_month_day_hour_min_secs) when the recording was made.

Notes:

Bugs: xhippo can get a bit mixed up (as if frozen) if you immediately reload the recorded file; the "Play the previous song" button usually gets you out of trouble, or simply don't mix recording and playing back at the same time.

You can of course directly use the provided xhippo_record_mp3 and xhippo_record_wav scripts as commandline utilities without even needing xhippo (but then you don't have the nice pause control etc). Alternatively, it would be easy to modify them via gtkdialog, bacon, or say vala to provide an alternative gui frontend than xhippo or Precord. However, note that gtkdialog gui are not so fast as xhippo (which is itself written in C) and consume more resources in terms of runtime RAM usage.

Eventually, I'll upload a new xhippo dotpet which includes these alterations, but that may take a while... hence the attachments provided for now.
Attachments
xhippo.config.tar.gz
Associates special file extensions .mp3# and .wav# with recording
(2.31 KiB) Downloaded 295 times
xhippo_record_wav.tar.gz
Script to record wav files (with timestamps if desired)
(760 Bytes) Downloaded 289 times
xhippo_record_mp3.tar.gz
Script to record mp3 files (with timestamp if desired)
(803 Bytes) Downloaded 272 times
github mcewanw


Post Reply