annotate Plugins/Output/crossfade/timing.c @ 630:5b81b0f310e5 trunk

[svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
author chainsaw
date Sat, 11 Feb 2006 08:25:14 -0800
parents 88b38e2414a1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1 /* timing.c
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
3 * get timing info based on file name
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
4 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
5 * file name should have a comment like this :
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
6 * R(RMS)-T(in):(out):(end)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
7 * where :
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
8 * - RMS is an indication of the RMS value in between in and out
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
9 * (to be compared against maximum sample value, 32767 for 16 bit audio)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
10 * - in, out and end are floats, giving the mixing start and end points
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
11 * and the length of the file in seconds
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
12 */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
13
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
14 #include "timing.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
15 #include "crossfade.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
16 #include "debug.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
17
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
18 #include <stdio.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
19 #include <locale.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
20
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
21 #undef VERBOSE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
22
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
23 #ifdef VOLUME_NORMALIZER
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
24
630
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
25 int
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
26 get_timing_comment(char *filename, quantaudio_t * qa)
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
27 /*
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
28 * check if the file given has a timing comment
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
29 * return 1 if it does and 0 if it doesn't
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
30 * store the relevant data in quantaudio
630
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
31 */
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
32 {
630
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
33 id3_t id3;
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
34 int nscanned;
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
35
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
36 setlocale(LC_NUMERIC, "C");
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
37
630
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
38 get_id3(filename, &id3);
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
39 if ((nscanned = sscanf(id3.comment, "R:%d-T:%f:%f:%f", &qa->RMS, &qa->mix_in, &qa->mix_out, &qa->length)) < 4)
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
40 {
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
41 /* tag not right */
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
42 #ifdef VERBOSE
630
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
43 DEBUG(("[crossfade] get_timing_comment: no quantaudio comment\n"));
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
44 DEBUG(("[crossfade] get_timing_comment: nscanned=%d (\"%s\")\n", nscanned, id3.comment));
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
45 DEBUG(("[crossfade] get_timing_comment: in %.2f, out %.2f, length %.2f, RMS %d\n", qa->mix_in, qa->mix_out,
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
46 qa->length, qa->RMS));
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
47 #endif
630
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
48 return 0;
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
49 }
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
50 else
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
51 {
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
52 #ifdef VERBOSE
630
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
53 DEBUG(("[crossfade] get_timing_comment: in %.2f, out %.2f, length %.2f, RMS %d\n", qa->mix_in, qa->mix_out,
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
54 qa->length, qa->RMS));
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
55 #endif
630
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
56 return 1;
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
57 }
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
58 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
59
630
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
60 int
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
61 get_id3(char *filename, id3_t * id3)
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
62 /* get the id3 tag of this file. Return 0 when failed or 1 when ok */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
63 {
630
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
64 FILE *fp;
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
65 fp = fopen(filename, "r"); /* read only */
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
66 if (fp == NULL)
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
67 {
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
68 /* file didn't open */
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
69 DEBUG(("[crossfade] get_id3 : file %s didn't open !\n", filename));
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
70 return 0;
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
71 }
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
72 if (fseek(fp, -128, SEEK_END) < 0)
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
73 {
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
74 /* problem rewinding */
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
75 DEBUG(("[crossfade] get_id3 : problem rewinding on %s !\n", filename));
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
76 return 0;
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
77 }
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
78 else
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
79 {
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
80 /* we rewound successfully */
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
81 if (fread(id3, 128, 1, fp) < 0)
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
82 {
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
83 /* read error */
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
84 DEBUG(("[crossfade] get_id3 : read error on %s !\n", filename));
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
85 return 0;
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
86 }
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
87 }
5b81b0f310e5 [svn] Update codingstyle to be more consistent with last upstream release. Stop exploding at shutdown.
chainsaw
parents: 259
diff changeset
88 return 1;
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
89 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
90
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
91 #endif