0.3.3 (to be announced) "axiomatic perspectivity"
-------------------------------------------------
-Internal code cleanups and improved tag handling.
+Internal code cleanups, improved tag handling and the new
+amplification feature.
- para_server uses the generic scheduling code.
- overhaul of the virtual streaming system.
- mp3: id3 version 2 support via libid3tag (optional)
- ogg: vorbis comment support.
- mp3 audio format handler cleanups.
+ - new status item/database entry: amplification. It is
+ used by the compress filter to pre-amplify the amplitude of the
+ audio stream.
-----------------------------------------
0.3.2 (2008-04-11) "probabilistic parity"
continue;
ret = t->event_handler(event, pb, data);
if (ret < 0)
- PARA_CRIT_LOG("%s\n", para_strerror(-ret));
+ PARA_CRIT_LOG("table %s, event %d: %s\n", t->name,
+ event, para_strerror(-ret));
}
}
N: touch
P: AFS_READ | AFS_WRITE
D: Manipulate the afs data for all audio files matching a pattern.
-U: touch [-n numplayed] [-l lastplayed] [-y lyrics_id] [-i image_id] [-v] [-p] pattern
+U: touch [-n numplayed] [-l lastplayed] [-y lyrics_id] [-i image_id] [-a amp] [-v] [-p] pattern
H: If no option is given, lastplayed is set to the current time
H: and numplayed is increased by one. Otherwise, only the given
H: options are taken into account.
H:
H: -i Set the image id. Same as -y, but sets the image.
H:
+H: -a Set the amplification value (0-255). This determines a scaling
+H: factor by which the amplitude should be multiplied in order to
+H: normalize the volume of the audio file. A value of zero means
+H: no amplification, 64 means the amplitude should be multiplied
+H: by a factor of two, 128 by three and so on.
+H:
+H: This value is used by the compress filter.
+H:
H: -v Verbose mode. Explain what is being done.
H:
H: -p Pathname match. Match a slash in the path only with a slash
uint32_t lyrics_id;
/** Mp3, ogg or aac. */
uint8_t audio_format_id;
+ /** Amplification value. */
+ uint8_t amp;
};
/**
unsigned short duration_width;
/** size of the num played field. */
unsigned short num_played_width;
+ /** size of the amp field. */
+ unsigned short amp_width;
};
/** Data passed from the ls command handler to its callback function. */
AFSI_LYRICS_ID_OFFSET = 24,
/** Storage position of the .audio_format_id field. */
AFSI_AUDIO_FORMAT_ID_OFFSET = 28,
- /** 3 bytes reserved space for future usage. */
- AFSI_AUDIO_FORMAT_UNUSED_OFFSET = 29,
+ /** Storage position of the amplification field. */
+ AFSI_AMP_OFFSET = 29,
+ /** 2 bytes reserved space for future usage. */
+ AFSI_AUDIO_FORMAT_UNUSED_OFFSET = 30,
/** On-disk storage space needed. */
AFSI_SIZE = 32
};
write_u32(buf + AFSI_LYRICS_ID_OFFSET, afsi->lyrics_id);
write_u8(buf + AFSI_AUDIO_FORMAT_ID_OFFSET,
afsi->audio_format_id);
- memset(buf + AFSI_AUDIO_FORMAT_UNUSED_OFFSET, 0, 3);
+ write_u8(buf + AFSI_AMP_OFFSET, afsi->amp);
+ memset(buf + AFSI_AUDIO_FORMAT_UNUSED_OFFSET, 0, 2);
}
/**
afsi->lyrics_id = read_u32(buf + AFSI_LYRICS_ID_OFFSET);
afsi->audio_format_id = read_u8(buf +
AFSI_AUDIO_FORMAT_ID_OFFSET);
+ afsi->amp = read_u8(buf + AFSI_AMP_OFFSET);
return 1;
}
ret = para_printf(b,
"%s" /* score */
"%s " /* attributes */
+ "%*u " /* amp */
"%*d " /* image_id */
"%*d " /* lyrics_id */
"%*d " /* bitrate */
"%s\n", /* path */
score_buf,
att_buf,
+ w->amp_width, afsi->amp,
w->image_id_width, afsi->image_id,
w->lyrics_id_width, afsi->lyrics_id,
w->bitrate_width, afhi->bitrate,
"%s: %lu\n" /* seconds total */
"%s: %s\n" /* last played time */
"%s: %d\n" /* num_played */
+ "%s: %u\n" /* ampplification */
"%s" /* tag info */
"%s: %lu\n" /* chunk time */
"%s: %lu\n", /* num chunks */
status_item_list[SI_SECONDS_TOTAL], afhi->seconds_total,
status_item_list[SI_LAST_PLAYED], last_played_time,
status_item_list[SI_NUM_PLAYED], afsi->num_played,
+ status_item_list[SI_AMPLIFICATION], afsi->amp,
afhi->info_string,
status_item_list[SI_CHUNK_TIME], tv2ms(&afhi->chunk_tv),
status_item_list[SI_NUM_CHUNKS], afhi->chunks_total
/* get the number of chars to print this amount of time */
tmp = get_duration_width(d->afhi.seconds_total);
w->duration_width = PARA_MAX(w->duration_width, tmp);
+ GET_NUM_DIGITS(d->afsi.amp, &num_digits);
+ w->amp_width = PARA_MAX(w->amp_width, num_digits);
if (options->flags & LS_FLAG_ADMISSIBLE_ONLY) {
GET_NUM_DIGITS(score, &num_digits);
num_digits++; /* add one for the sign (space or "-") */
int32_t num_played;
/** New last played count. */
int64_t last_played;
- /** new lyrics id. */
+ /** New lyrics id. */
int32_t lyrics_id;
- /** new image id. */
+ /** New image id. */
int32_t image_id;
- /** command line flags (see \ref touch_flags). */
+ /** New amplification value. */
+ int32_t amp;
+ /** Command line flags (see \ref touch_flags). */
unsigned flags;
};
struct osl_object obj;
struct afs_info old_afsi, new_afsi;
int ret, no_options = tad->cto->num_played < 0 && tad->cto->last_played < 0 &&
- tad->cto->lyrics_id < 0 && tad->cto->image_id < 0;
+ tad->cto->lyrics_id < 0 && tad->cto->image_id < 0 && tad->cto->amp < 0;
struct afsi_change_event_data aced;
ret = get_afsi_object_of_row(row, &obj);
new_afsi.num_played = tad->cto->num_played;
if (tad->cto->last_played >= 0)
new_afsi.last_played = tad->cto->last_played;
+ if (tad->cto->amp >= 0)
+ new_afsi.amp = tad->cto->amp;
}
tad->num_matches++;
save_afsi(&new_afsi, &obj); /* in-place update */
.num_played = -1,
.last_played = -1,
.lyrics_id = -1,
- .image_id = -1
+ .image_id = -1,
+ .amp = -1,
};
struct osl_object query = {.data = &cto, .size = sizeof(cto)};
int i, ret;
return ret;
continue;
}
+ if (!strncmp(arg, "-a", 2)) {
+ int32_t val;
+ ret = para_atoi32(arg + 2, &val);
+ if (ret < 0)
+ return ret;
+ if (val < 0 || val > 255)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+ cto.amp = val;
+ continue;
+ }
if (!strcmp(arg, "-p")) {
cto.flags |= TOUCH_FLAG_FNM_PATHNAME;
continue;
struct slot_info slot[MAX_STREAM_SLOTS];
+/** The array of status items sent by para_server. */
+char *stat_item_values[NUM_STAT_ITEMS] = {NULL};
+
/**
* the current mode of operation of which can be changed by the on/off/cycle
* commands. It is either, AUDIOD_OFF, AUDIOD_ON or AUDIOD_STANDBY.
*
* \sa struct status_task
*/
-struct status_task *stat_task = &status_task_struct;
+static struct status_task *stat_task = &status_task_struct;
static struct timeval initial_delay_barrier;
/**
return -E_UNSUPPORTED_AUDIO_FORMAT;
}
+char *get_time_string(struct timeval *newest_stime)
+{
+ struct timeval diff, adj_stream_start, tmp;
+ int total = 0, use_server_time = 1,
+ length_seconds = stat_task->length_seconds;
+
+ if (!stat_task->playing) {
+ if (length_seconds)
+ return NULL;
+ return make_message("%s:\n", status_item_list[SI_PLAY_TIME]);
+ }
+ if (audiod_status == AUDIOD_OFF)
+ goto out;
+ if (stat_task->sa_time_diff_sign > 0)
+ tv_diff(&stat_task->server_stream_start, &stat_task->sa_time_diff,
+ &adj_stream_start);
+ else
+ tv_add(&stat_task->server_stream_start, &stat_task->sa_time_diff,
+ &adj_stream_start);
+ tmp = adj_stream_start;
+ if (newest_stime && audiod_status == AUDIOD_ON) {
+ tv_diff(newest_stime, &adj_stream_start, &diff);
+ if (tv2ms(&diff) < 5000) {
+ tmp = *newest_stime;
+ use_server_time = 0;
+ }
+ }
+ tv_diff(now, &tmp, &diff);
+ total = diff.tv_sec + stat_task->offset_seconds;
+ if (total > length_seconds)
+ total = length_seconds;
+ if (total < 0)
+ total = 0;
+out:
+ return make_message(
+ "%s: %s%d:%02d [%d:%02d] (%d%%/%d:%02d)\n",
+ status_item_list[SI_PLAY_TIME],
+ use_server_time? "~" : "",
+ total / 60,
+ total % 60,
+ (length_seconds - total) / 60,
+ (length_seconds - total) % 60,
+ length_seconds? (total * 100 + length_seconds / 2) /
+ length_seconds : 0,
+ length_seconds / 60,
+ length_seconds % 60
+ );
+}
+
/**
* the log function of para_audiod
*
tmp = make_message("%s\n", line);
stat_client_write(tmp, itemnum);
free(tmp);
- free(stat_task->stat_item_values[itemnum]);
- stat_task->stat_item_values[itemnum] = para_strdup(line);
+ free(stat_item_values[itemnum]);
+ stat_item_values[itemnum] = para_strdup(line);
ilen = strlen(status_item_list[itemnum]);
switch (itemnum) {
case SI_STATUS:
client_close(stat_task->ct);
stat_task->ct = NULL;
FOR_EACH_STATUS_ITEM(i) {
- free(stat_task->stat_item_values[i]);
- stat_task->stat_item_values[i] = NULL;
+ free(stat_item_values[i]);
+ stat_item_values[i] = NULL;
}
dump_empty_status();
stat_task->length_seconds = 0;
stat_task->offset_seconds = 0;
audiod_status_dump();
stat_task->playing = 0;
- stat_task->stat_item_values[SI_BASENAME] = make_message(
+ stat_item_values[SI_BASENAME] = make_message(
"%s: no connection to para_server\n",
status_item_list[SI_BASENAME]);
- stat_client_write(stat_task->stat_item_values[SI_BASENAME],
+ stat_client_write(stat_item_values[SI_BASENAME],
SI_BASENAME);
}
struct task task;
/** client data associated with the stat task */
struct client_task *ct;
- /** the array of status items sent by para_server */
- char *stat_item_values[NUM_STAT_ITEMS];
/** do not restart client command until this time */
struct timeval restart_barrier;
/** last time we received status data from para_server */
int current_audio_format_num;
};
-extern struct status_task *stat_task;
extern struct slot_info slot[MAX_STREAM_SLOTS];
extern struct audiod_args_info conf;
extern int audiod_status;
int handle_connect(int accept_fd);
void audiod_status_dump(void);
void dump_empty_status(void);
+char *get_time_string(struct timeval *newest_stime);
/** iterate over all slots */
#define FOR_EACH_SLOT(_slot) for (_slot = 0; _slot < MAX_STREAM_SLOTS; _slot++)
#include "fd.h"
#include "audiod_command_list.h"
+extern char *stat_item_values[NUM_STAT_ITEMS];
+
+
/** iterate over the array of all audiod commands */
#define FOR_EACH_COMMAND(c) for (c = 0; audiod_cmds[c].name; c++)
return write(fd, buf, len) != len? -E_CLIENT_WRITE: 1;
}
-static char *get_time_string(struct timeval *newest_stime)
-{
- struct timeval diff, adj_stream_start, tmp;
- int total = 0, use_server_time = 1,
- length_seconds = stat_task->length_seconds;
-
- if (!stat_task->playing) {
- if (length_seconds)
- return NULL;
- return make_message("%s:\n", status_item_list[SI_PLAY_TIME]);
- }
- if (audiod_status == AUDIOD_OFF)
- goto out;
- if (stat_task->sa_time_diff_sign > 0)
- tv_diff(&stat_task->server_stream_start, &stat_task->sa_time_diff,
- &adj_stream_start);
- else
- tv_add(&stat_task->server_stream_start, &stat_task->sa_time_diff,
- &adj_stream_start);
- tmp = adj_stream_start;
- if (newest_stime && audiod_status == AUDIOD_ON) {
- tv_diff(newest_stime, &adj_stream_start, &diff);
- if (tv2ms(&diff) < 5000) {
- tmp = *newest_stime;
- use_server_time = 0;
- }
- }
- tv_diff(now, &tmp, &diff);
- total = diff.tv_sec + stat_task->offset_seconds;
- if (total > length_seconds)
- total = length_seconds;
- if (total < 0)
- total = 0;
-out:
- return make_message(
- "%s: %s%d:%02d [%d:%02d] (%d%%/%d:%02d)\n",
- status_item_list[SI_PLAY_TIME],
- use_server_time? "~" : "",
- total / 60,
- total % 60,
- (length_seconds - total) / 60,
- (length_seconds - total) % 60,
- length_seconds? (total * 100 + length_seconds / 2) /
- length_seconds : 0,
- length_seconds / 60,
- length_seconds % 60
- );
-}
-
__malloc static char *audiod_status_string(void)
{
const char *status = (audiod_status == AUDIOD_ON)?
char *tmp, *v;
if (!((1 << i) & mask))
continue;
- v = stat_task->stat_item_values[i];
+ v = stat_item_values[i];
tmp = make_message("%s%s%s", buf? buf: "",
v? v : "", v? "\n" : "");
free(buf);
struct timeval *t = wstime();
char *old, *new, *tmp;
- old = stat_task->stat_item_values[SI_PLAY_TIME];
+ old = stat_item_values[SI_PLAY_TIME];
new = get_time_string(t);
if (new) {
if (!old || strcmp(old, new)) {
free(old);
stat_client_write(new, SI_PLAY_TIME);
- stat_task->stat_item_values[SI_PLAY_TIME] = new;
+ stat_item_values[SI_PLAY_TIME] = new;
} else
free(new);
}
new = uptime_str();
- old = stat_task->stat_item_values[SI_AUDIOD_UPTIME];
+ old = stat_item_values[SI_AUDIOD_UPTIME];
if (!old || strcmp(old, new)) {
free(old);
tmp = make_message("%s: %s\n",
status_item_list[SI_AUDIOD_UPTIME], new);
stat_client_write(tmp, SI_AUDIOD_UPTIME);
free(tmp);
- stat_task->stat_item_values[SI_AUDIOD_UPTIME] = new;
+ stat_item_values[SI_AUDIOD_UPTIME] = new;
} else
free(new);
- old = stat_task->stat_item_values[SI_AUDIOD_STATUS];
+ old = stat_item_values[SI_AUDIOD_STATUS];
new = audiod_status_string();
if (!old || strcmp(old, new)) {
free(old);
stat_client_write(new, SI_AUDIOD_STATUS);
- stat_task->stat_item_values[SI_AUDIOD_STATUS] = new;
+ stat_item_values[SI_AUDIOD_STATUS] = new;
} else
free(new);
- old = stat_task->stat_item_values[SI_DECODER_FLAGS];
+ old = stat_item_values[SI_DECODER_FLAGS];
new = decoder_flags();
if (!old || strcmp(old, new)) {
free(old);
stat_client_write(new, SI_DECODER_FLAGS);
- stat_task->stat_item_values[SI_DECODER_FLAGS] = new;
+ stat_item_values[SI_DECODER_FLAGS] = new;
} else
free(new);
}
char *tmp = make_message("%s:\n", status_item_list[i]);
stat_client_write(tmp, i);
free(tmp);
- free(stat_task->stat_item_values[i]);
- stat_task->stat_item_values[i] = NULL;
+ free(stat_item_values[i]);
+ stat_item_values[i] = NULL;
}
}
#include "sched.h"
#include "filter.h"
#include "string.h"
+#include "audiod.h"
/** The size of the output data buffer. */
#define COMPRESS_CHUNK_SIZE 40960
+extern char *stat_item_values[NUM_STAT_ITEMS];
+
/** Data specific to the compress filter. */
struct private_compress_data {
/** The current multiplier. */
unsigned num_samples;
/** Absolute value of the maximal sample in the current block. */
unsigned peak;
+ /** Amplification factor. */
+ unsigned amp;
};
static ssize_t compress(char *inbuf, size_t inbuf_len, struct filter_node *fn)
return 0;
for (i = 0; i < length / 2; i++) {
/* be careful in that heat, my dear */
- int sample = *ip++, adjusted_sample;
+ int sample = *ip++, adjusted_sample = (PARA_ABS(sample) * (64 + pcd->amp)) >> 6;
- adjusted_sample = (PARA_ABS(sample) * pcd->current_gain)
- >> gain_shift;
+ adjusted_sample = (adjusted_sample * pcd->current_gain) >> gain_shift;
if (unlikely(adjusted_sample > 32767)) { /* clip */
PARA_NOTICE_LOG("clip: sample: %d, adjusted sample: %d\n",
sample, adjusted_sample);
fn->buf = para_malloc(fn->bufsize);
pcd->current_gain = 1 << pcd->conf->inertia_arg;
pcd->max_gain = 1 << (pcd->conf->inertia_arg + pcd->conf->aggressiveness_arg);
+ if (stat_item_values[SI_AMPLIFICATION]) {
+ int i = SI_AMPLIFICATION;
+ char *s = stat_item_values[i] + strlen(status_item_list[i]) + 1;
+ sscanf(s, "%u", &pcd->amp);
+ }
+ PARA_NOTICE_LOG("amplification: %u (scaling factor: %1.2f)\n", pcd->amp,
+ pcd->amp / 64.0 + 1.0);
}
/**
attributes_txt decoder_flags audiod_status play_time attributes_bitmap
offset seconds_total stream_start current_time audiod_uptime image_id
lyrics_id duration directory lyrics_name image_name path hash channels
-last_played num_chunks chunk_time"
+last_played num_chunks chunk_time amplification"
# $1: prefix, $2: items
AC_DEFUN([make_enum_items], [$(
#include "stdout.h"
#include "error.h"
+/** The list of all status items used by para_{server,audiod,gui}. */
+const char *status_item_list[] = {STATUS_ITEM_ARRAY};
+
+char *stat_item_values[NUM_STAT_ITEMS] = {NULL};
+
/** Initialize the array of errors for para_filter. */
INIT_FILTER_ERRLISTS;
.size = sizeof(aft_row)};
int ret = osl_get_row(score_table, SCORECOL_AFT_ROW, &obj, &row);
+ if (ret == -E_RB_KEY_NOT_FOUND) /* not an error */
+ return 1;
if (ret < 0)
return ret;
ret = get_num_admissible_files(&n);