Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

o README update.

o Play around with WAV. Does not seem to properly re-code. Assumption
  right now is, that the header is not complete.
  • Loading branch information...
commit 31bd9ce1836eeec85e97441990ec7022ce604180 1 parent 7c7bda6
@hzeller authored
Showing with 51 additions and 41 deletions.
  1. +27 −9 README
  2. +1 −4 conversion-buffer.cc
  3. +22 −27 convolver.cc
  4. +1 −1  fuse-convolve.c
View
36 README
@@ -1,19 +1,37 @@
-A fuse filesystem that takes an original path to wav and flac files and provides
-these files that are convolved on the fly using the zita convolver (usually
-used in jconvolve)
+A fuse filesystem that takes an original path to a directory with flac-files
+and provides these files that are convolved on the fly using the zita convolver
+(usually used in jconvolve).
-** To compile on Ubuntu **
+=== To compile on Ubuntu ===
$ sudo aptitude install libsndfile-dev libflac-dev libzita-convolver-dev libfuse-dev
$ make
-** Run **
-./fuse-convolve filter.conf /path/to/original/fileystem /mnt/mountpoint -f
+=== Run ===
-The '-f' lets it run in foreground (useful, since right now this spits out
-some debugging information.
+ ./fuse-convolve /directory/with/filters /path/to/original/fileystem /mnt/mountpoint -f
-Access fileystem under /mnt/mountpoint, e.g.
+Parameters:
+ 1) The /directory/with/filters needs to be a directory that has
+ jconvolver filter-configuration files with the following naming:
+
+ filter-<samplerate>-<bits>-<channels>.conf
+
+ So if you have flac files with 44.1khz, 16 bits and 2 channel stero,
+ you need a filter configuration named:
+
+ /directory/with/filters/filter-44100-16-2.conf
+
+
+ 2) The original directory that contains the *.flac files.
+
+ 3) The mount point.
+
+
+The '-f' option lets it run in foreground (useful, since right now this
+spits out some debugging information.
+
+Now you can access the fileystem under that mount point, e.g.
mplayer /mnt/mountpoint/foo.flac
(purely readonly; only reading files is supported).
View
5 conversion-buffer.cc
@@ -96,8 +96,5 @@ ssize_t ConversionBuffer::Read(char *buf, size_t size, off_t offset) {
if (!source_->AddMoreSoundData())
break;
}
- ssize_t result = pread(tmpfile_, buf, size, offset);
- //fprintf(stderr, "Read(%ld @ %ld) = %ld\n", size, offset, result);
-
- return result;
+ return pread(tmpfile_, buf, size, offset);
}
View
49 convolver.cc
@@ -28,17 +28,6 @@
const char *global_zita_config_dir = NULL;
-// We do a very simple decision which filter to apply by looking at the suffix.
-static bool HasSuffixString (const char *str, const char *suffix) {
- if (!str || !suffix)
- return false;
- size_t str_len = strlen(str);
- size_t suffix_len = strlen(suffix);
- if (suffix_len > str_len)
- return false;
- return strncasecmp(str + str_len - suffix_len, suffix, suffix_len) == 0;
-}
-
namespace {
class FileFilter : public filter_object_t {
public:
@@ -86,8 +75,8 @@ class SndFileFilter :
}
int bits = 16;
- if ((in_info.format & SF_FORMAT_PCM_24) != 0) bits = 24;
- if ((in_info.format & SF_FORMAT_PCM_32) != 0) bits = 32;
+ if ((in_info.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_24) bits = 24;
+ if ((in_info.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_32) bits = 32;
char config_path[1024];
snprintf(config_path, sizeof(config_path), "%s/filter-%d-%d-%d.conf",
global_zita_config_dir, in_info.samplerate,
@@ -147,21 +136,25 @@ class SndFileFilter :
// format that we choose here. Essentially we want to have mostly what
// our input is.
struct SF_INFO out_info = in_info;
- // The input seems to contain several bits indicating all kinds major
- // types. So look at the filename.
- if (HasSuffixString(path, ".wav")) {
- out_info.format = SF_FORMAT_WAV;
- } else {
+ out_info.seekable = 0;
+ if ((in_info.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_OGG) {
+ // If the input was ogg, we're re-coding this to flac/24.
out_info.format = SF_FORMAT_FLAC;
- }
- // same number of bits format as input. If the input was ogg, we're
- // re-coding this to flac/24.
- if ((in_info.format & SF_FORMAT_OGG) != 0) {
out_info.format |= SF_FORMAT_PCM_24;
- } else {
- out_info.format |= in_info.format & SF_FORMAT_SUBMASK;
}
- out_info.seekable = 0; // no point in making it seekable.
+ else if ((in_info.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV
+ && (in_info.format & SF_FORMAT_SUBMASK) != SF_FORMAT_PCM_16) {
+ // WAV format seems to create garbage when we attempt to output PCM_24
+ // Output float for now; still mplayer seems to trip about length.
+ // Probably the header is incomplete. Investigate.
+ out_info.format = SF_FORMAT_WAV;
+ out_info.format |= SF_FORMAT_FLOAT;
+ out_info.format |= SF_ENDIAN_CPU;
+ }
+ else { // original format.
+ out_info.format = in_info.format;
+ }
+
output_buffer_ = new ConversionBuffer(this, out_info);
}
@@ -202,7 +195,7 @@ class SndFileFilter :
if (r == (int) zita_.fragm) {
fprintf(stderr, ".");
} else {
- fprintf(stderr, "[%d]\n", r);
+ fprintf(stderr, "[%d]", r);
}
if (r < (int) zita_.fragm) {
// zero out the rest of the buffer
@@ -230,7 +223,9 @@ class SndFileFilter :
}
sf_writef_float(snd_out_, raw_sample_buffer_, r);
input_frames_left_ -= r;
-
+ if (input_frames_left_ == 0) {
+ fprintf(stderr, "(fully decoded)\n");
+ }
return input_frames_left_;
}
View
2  fuse-convolve.c
@@ -171,7 +171,7 @@ static struct fuse_operations fuseconv_operations = {
};
static int usage(const char *prog) {
- fprintf(stderr, "usage: %s <config-file> <original-dir> <mount-point>\n",
+ fprintf(stderr, "usage: %s <config-dir> <original-dir> <mount-point>\n",
prog);
return 1;
}
Please sign in to comment.
Something went wrong with that request. Please try again.