Flac and Audio CD Health Checks
On Sat, 23 May 2015 10:57:37 +0100, Jim Lesurf wrote:
That looks like worth trying. However I'm not clear on details so would
like to check some points:
1) When calling flac using system() can I just replace the flac
command's final switch/setting
I don't use flac but did read its manpage. That says that if you read the
input from stdin, the output gets written to stdout, i.e. in this mode
flac is intended to be used as one element in a pipeline. OTOH, if your
input comes from a file named in the command line, the output will be
written to a named output file.
-o outputfile
If it understood the manpage correctly, if you want to use this, the
input should be read from a named file
with something like
inputfile | RunImage
Again, if I read the manpage correctly. this should be used in a pipeline:
flac inputfile | next_program_in_the_pipeline
OR, presumably.
flac inputfile outfile
would also work.
Will the output be readable as a stream of bytes/chars I can use to fill
a buffer?
....but don't take my word for it: read the manpage and try the various
options for yourself using a small input file and some program like
'hexdump' to examine the output file and see what got written to it.
===== change of topic ======
FILE flacfile = tmpfile();
No.
FILE* flacfile = tmpfile();
is a C statement that creates a variable called flacfile that your
program can use to store sequential data that will be written into
flacfile and read back (one or more times) by your program. flacfile is a
variable created within your program and obeys variable normal scoping
rules. It is never written to the filing system because it has no name
that can ever be seen from outside your program. If you want to save its
content as a file, you'd need to open an output file and copy its
contents into that.
will mean it will read as stdin when I use flacfile as the 'handle'?
No. See above. You can fill it with fwrite(), and access it with rewind()
or fseek() and friends followed with fread(). If the flacfile variable
goes out of scope the data it contains will be discarded and the memory
that held the data will be released. If you call fclose() the data will
be lost.
Can I also use fread() of the correctly sized block rather than read as
a series of bytes/chars/etc?
Yes. Because it has a variable type of FILE* all the usual fread(), fwrite
(), fseek(), rewind() etc operations should work on it but, because it
exists only in the RAM occupied by your program, these should all be fast
operations unless, of course, you put so much data into it that it
overflows physical RAM and parts of it get written to swap space.
Is there an example I can see of this? I'll do a websearch, but as yet
don't know anything about it!
Pass. Try searching for examples.
Thanks again, this is interesting. I've know of the existence and
general pupose of pipes, but no idea how to use them.
This isn't a pipeline, which is a command line construct, e.g.
ls -ll *.c | sort --key=5 -g
is a pipeline that lists the details of all C source files "ls -ll *.c"
and sorts the files by size "sort --key=5 -g". '|' is the pipeline symbol
that says that the output that 'ls' writes to stdout will be fed into the
stdin input of 'sort'
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
|