Simulator first commit
This commit is contained in:
48
node_modules/lame/deps/mpg123/doc/examples/Makefile
generated
vendored
Normal file
48
node_modules/lame/deps/mpg123/doc/examples/Makefile
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
targets = feedseek mpg123_to_wav mpg123_to_wav_replaced_io scan id3dump mpglib dump_seekindex extract_frames
|
||||
|
||||
all: $(targets)
|
||||
|
||||
# On largefile-aware systems you might want to use these instead:
|
||||
#MPG123_CFLAGS := $(shell pkg-config --cflags libmpg123_64)
|
||||
#MPG123_LDFLAGS := $(shell pkg-config --libs libmpg123_64)
|
||||
# This works on sane setups where off_t is off_t, and just that.
|
||||
ifeq ($(MPG123_PREFIX),)
|
||||
MPG123_CFLAGS := $(shell pkg-config --cflags libmpg123)
|
||||
MPG123_LDFLAGS := $(shell pkg-config --libs libmpg123)
|
||||
else # Yeah, that's with GNU/Linux in mind, at least GNU ld ...
|
||||
MPG123_CFLAGS := -I$(MPG123_PREFIX)/include
|
||||
MPG123_LDFLAGS := -L$(MPG123_PREFIX)/lib -Wl,-rpath $(MPG123_PREFIX)/lib -lmpg123
|
||||
endif
|
||||
SND_CFLAGS := $(shell pkg-config --cflags sndfile)
|
||||
SND_LDFLAGS := $(shell pkg-config --libs sndfile)
|
||||
|
||||
# Oder of libs not that important here...
|
||||
compile = $(CC) $(CPPFLAGS) $(CFLAGS) $(MPG123_CFLAGS)
|
||||
linkflags = $(MPG123_LDFLAGS) $(LDFLAGS)
|
||||
|
||||
mpg123_to_wav: mpg123_to_wav.c
|
||||
$(compile) -o mpg123_to_wav mpg123_to_wav.c $(SND_CFLAGS) $(SND_LDFLAGS) $(linkflags)
|
||||
|
||||
mpg123_to_wav_replaced_io: mpg123_to_wav_replaced_io.c
|
||||
$(compile) -o $@ $< $(SND_CFLAGS) $(SND_LDFLAGS) $(linkflags)
|
||||
|
||||
feedseek: feedseek.c
|
||||
$(compile) -o feedseek feedseek.c $(linkflags)
|
||||
|
||||
scan: scan.c
|
||||
$(compile) -o scan scan.c $(linkflags)
|
||||
|
||||
id3dump:id3dump.c
|
||||
$(compile) -o id3dump id3dump.c $(linkflags)
|
||||
|
||||
dump_seekindex: dump_seekindex.c
|
||||
$(compile) -o dump_seekindex dump_seekindex.c $(linkflags)
|
||||
|
||||
mpglib: mpglib.c
|
||||
$(compile) -o mpglib mpglib.c $(linkflags)
|
||||
|
||||
extract_frames: extract_frames.c
|
||||
$(compile) -o $@ $< $(linkflags)
|
||||
|
||||
clean:
|
||||
rm -vf $(targets)
|
41
node_modules/lame/deps/mpg123/doc/examples/dump_seekindex.c
generated
vendored
Normal file
41
node_modules/lame/deps/mpg123/doc/examples/dump_seekindex.c
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
dump_seekindex: Scan a mpeg file and dump its seek index.
|
||||
|
||||
copyright 2010 by the mpg123 project - free software under the terms of the LGPL 2.1
|
||||
see COPYING and AUTHORS files in distribution or http://mpg123.org
|
||||
initially written by Patrick Dehne
|
||||
*/
|
||||
|
||||
#include <mpg123.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
mpg123_handle *m;
|
||||
off_t* offsets;
|
||||
off_t step;
|
||||
size_t fill, i;
|
||||
|
||||
if(argc != 2)
|
||||
{
|
||||
fprintf(stderr, "\nI will dump the frame index of an MPEG audio file.\n");
|
||||
fprintf(stderr, "\nUsage: %s <mpeg audio file>\n\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
mpg123_init();
|
||||
m = mpg123_new(NULL, NULL);
|
||||
mpg123_param(m, MPG123_RESYNC_LIMIT, -1, 0);
|
||||
mpg123_param(m, MPG123_INDEX_SIZE, -1, 0);
|
||||
mpg123_open(m, argv[1]);
|
||||
mpg123_scan(m);
|
||||
|
||||
mpg123_index(m, &offsets, &step, &fill);
|
||||
for(i=0; i<fill;i++) {
|
||||
printf("Frame number %d: file offset %d\n", i * step, offsets[i]);
|
||||
}
|
||||
|
||||
mpg123_close(m);
|
||||
mpg123_delete(m);
|
||||
mpg123_exit();
|
||||
return 0;
|
||||
}
|
92
node_modules/lame/deps/mpg123/doc/examples/extract_frames.c
generated
vendored
Normal file
92
node_modules/lame/deps/mpg123/doc/examples/extract_frames.c
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
extract_frams: utlize the framebyframe API and mpg123_framedata to extract the MPEG frames out of a stream (strip off anything else).
|
||||
|
||||
copyright 2011 by the mpg123 project - free software under the terms of the LGPL 2.1
|
||||
see COPYING and AUTHORS files in distribution or http://mpg123.org
|
||||
initially written by Thomas Orgis
|
||||
*/
|
||||
|
||||
#include <mpg123.h>
|
||||
|
||||
/* unistd.h is not available under MSVC,
|
||||
io.h defines the read and write functions */
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int do_work(mpg123_handle *m);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
mpg123_handle *m;
|
||||
|
||||
mpg123_init();
|
||||
m = mpg123_new(NULL, &ret);
|
||||
|
||||
if(m == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot create handle: %s", mpg123_plain_strerror(ret));
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "I'll take your dirty MPEG audio from standard input and will write the extrated pure MPEG data to stadard output.\n");
|
||||
if(argc > 1 && strcmp(argv[1], "--noinfo") == 0)
|
||||
{
|
||||
fprintf(stderr, "Enabling parsing/consuming of the Info frame so that it will not appear in output.\n");
|
||||
ret = mpg123_param(m, MPG123_REMOVE_FLAGS, MPG123_IGNORE_INFOFRAME, 0.);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "If you'd have given --noinfo as argument, I would omit a LAME/Xing info frame.\n");
|
||||
ret = mpg123_param(m, MPG123_ADD_FLAGS, MPG123_IGNORE_INFOFRAME, 0.);
|
||||
}
|
||||
if(ret == 0) ret = do_work(m);
|
||||
|
||||
if(ret != 0) fprintf(stderr, "Some error occured: %s\n", mpg123_strerror(m));
|
||||
|
||||
|
||||
mpg123_delete(m); /* Closes, too. */
|
||||
}
|
||||
mpg123_exit();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int do_work(mpg123_handle *m)
|
||||
{
|
||||
int ret;
|
||||
size_t count = 0;
|
||||
ret = mpg123_open_fd(m, STDIN_FILENO);
|
||||
if(ret != MPG123_OK) return ret;
|
||||
|
||||
while( (ret = mpg123_framebyframe_next(m)) == MPG123_OK || ret == MPG123_NEW_FORMAT )
|
||||
{
|
||||
unsigned long header;
|
||||
unsigned char *bodydata;
|
||||
size_t bodybytes;
|
||||
if(mpg123_framedata(m, &header, &bodydata, &bodybytes) == MPG123_OK)
|
||||
{
|
||||
/* Need to extract the 4 header bytes from the native storage in the correct order. */
|
||||
unsigned char hbuf[4];
|
||||
int i;
|
||||
for(i=0; i<4; ++i) hbuf[i] = (unsigned char) ((header >> ((3-i)*8)) & 0xff);
|
||||
|
||||
/* Now write out both header and data, fire and forget. */
|
||||
write(STDOUT_FILENO, hbuf, 4);
|
||||
write(STDOUT_FILENO, bodydata, bodybytes);
|
||||
fprintf(stderr, "%zu: header 0x%08x, %zu body bytes\n", ++count, header, bodybytes);
|
||||
}
|
||||
}
|
||||
|
||||
if(ret != MPG123_DONE)
|
||||
fprintf(stderr, "Some error occured (non-fatal?): %s\n", mpg123_strerror(m));
|
||||
|
||||
fprintf(stderr, "Done with %zu MPEG frames.\n", count);
|
||||
|
||||
return 0;
|
||||
}
|
238
node_modules/lame/deps/mpg123/doc/examples/feedseek.c
generated
vendored
Normal file
238
node_modules/lame/deps/mpg123/doc/examples/feedseek.c
generated
vendored
Normal file
@ -0,0 +1,238 @@
|
||||
/*
|
||||
feedseek: test program for libmpg123, showing how to use fuzzy seeking in feeder mode
|
||||
copyright 2008 by the mpg123 project - free software under the terms of the LGPL 2.1
|
||||
see COPYING and AUTHORS files in distribution or http://mpg123.org
|
||||
*/
|
||||
|
||||
#include <mpg123.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define INBUFF 16384 * 2 * 2
|
||||
#define WAVE_FORMAT_PCM 0x0001
|
||||
#define WAVE_FORMAT_IEEE_FLOAT 0x0003
|
||||
|
||||
FILE *out;
|
||||
size_t totaloffset, dataoffset;
|
||||
long rate;
|
||||
int channels, enc;
|
||||
unsigned short bitspersample, wavformat;
|
||||
|
||||
// write wav header
|
||||
void initwav()
|
||||
{
|
||||
unsigned int tmp32 = 0;
|
||||
unsigned short tmp16 = 0;
|
||||
|
||||
fwrite("RIFF", 1, 4, out);
|
||||
totaloffset = ftell(out);
|
||||
|
||||
fwrite(&tmp32, 1, 4, out); // total size
|
||||
fwrite("WAVE", 1, 4, out);
|
||||
fwrite("fmt ", 1, 4, out);
|
||||
tmp32 = 16;
|
||||
fwrite(&tmp32, 1, 4, out); // format length
|
||||
tmp16 = wavformat;
|
||||
fwrite(&tmp16, 1, 2, out); // format
|
||||
tmp16 = channels;
|
||||
fwrite(&tmp16, 1, 2, out); // channels
|
||||
tmp32 = rate;
|
||||
fwrite(&tmp32, 1, 4, out); // sample rate
|
||||
tmp32 = rate * bitspersample/8 * channels;
|
||||
fwrite(&tmp32, 1, 4, out); // bytes / second
|
||||
tmp16 = bitspersample/8 * channels; // float 16 or signed int 16
|
||||
fwrite(&tmp16, 1, 2, out); // block align
|
||||
tmp16 = bitspersample;
|
||||
fwrite(&tmp16, 1, 2, out); // bits per sample
|
||||
fwrite("data ", 1, 4, out);
|
||||
tmp32 = 0;
|
||||
dataoffset = ftell(out);
|
||||
fwrite(&tmp32, 1, 4, out); // data length
|
||||
}
|
||||
|
||||
// rewrite wav header with final length infos
|
||||
void closewav()
|
||||
{
|
||||
unsigned int tmp32 = 0;
|
||||
unsigned short tmp16 = 0;
|
||||
|
||||
long total = ftell(out);
|
||||
fseek(out, totaloffset, SEEK_SET);
|
||||
tmp32 = total - (totaloffset + 4);
|
||||
fwrite(&tmp32, 1, 4, out);
|
||||
fseek(out, dataoffset, SEEK_SET);
|
||||
tmp32 = total - (dataoffset + 4);
|
||||
|
||||
fwrite(&tmp32, 1, 4, out);
|
||||
}
|
||||
|
||||
// determine correct wav format and bits per sample
|
||||
// from mpg123 enc value
|
||||
void initwavformat()
|
||||
{
|
||||
if(enc & MPG123_ENC_FLOAT_64)
|
||||
{
|
||||
bitspersample = 64;
|
||||
wavformat = WAVE_FORMAT_IEEE_FLOAT;
|
||||
}
|
||||
else if(enc & MPG123_ENC_FLOAT_32)
|
||||
{
|
||||
bitspersample = 32;
|
||||
wavformat = WAVE_FORMAT_IEEE_FLOAT;
|
||||
}
|
||||
else if(enc & MPG123_ENC_16)
|
||||
{
|
||||
bitspersample = 16;
|
||||
wavformat = WAVE_FORMAT_PCM;
|
||||
}
|
||||
else
|
||||
{
|
||||
bitspersample = 8;
|
||||
wavformat = WAVE_FORMAT_PCM;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unsigned char buf[INBUFF];
|
||||
unsigned char *audio;
|
||||
FILE *in;
|
||||
mpg123_handle *m;
|
||||
int ret, state;
|
||||
size_t inc, outc;
|
||||
off_t len, num;
|
||||
size_t bytes;
|
||||
off_t inoffset;
|
||||
inc = outc = 0;
|
||||
|
||||
if(argc < 3)
|
||||
{
|
||||
fprintf(stderr,"Please supply in and out filenames\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
mpg123_init();
|
||||
|
||||
m = mpg123_new(NULL, &ret);
|
||||
if(m == NULL)
|
||||
{
|
||||
fprintf(stderr,"Unable to create mpg123 handle: %s\n", mpg123_plain_strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
mpg123_param(m, MPG123_VERBOSE, 2, 0);
|
||||
|
||||
ret = mpg123_param(m, MPG123_FLAGS, MPG123_FUZZY | MPG123_SEEKBUFFER | MPG123_GAPLESS, 0);
|
||||
if(ret != MPG123_OK)
|
||||
{
|
||||
fprintf(stderr,"Unable to set library options: %s\n", mpg123_plain_strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Let the seek index auto-grow and contain an entry for every frame
|
||||
ret = mpg123_param(m, MPG123_INDEX_SIZE, -1, 0);
|
||||
if(ret != MPG123_OK)
|
||||
{
|
||||
fprintf(stderr,"Unable to set index size: %s\n", mpg123_plain_strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = mpg123_format_none(m);
|
||||
if(ret != MPG123_OK)
|
||||
{
|
||||
fprintf(stderr,"Unable to disable all output formats: %s\n", mpg123_plain_strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Use float output
|
||||
ret = mpg123_format(m, 44100, MPG123_MONO | MPG123_STEREO, MPG123_ENC_FLOAT_32);
|
||||
if(ret != MPG123_OK)
|
||||
{
|
||||
fprintf(stderr,"Unable to set float output formats: %s\n", mpg123_plain_strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = mpg123_open_feed(m);
|
||||
if(ret != MPG123_OK)
|
||||
{
|
||||
fprintf(stderr,"Unable open feed: %s\n", mpg123_plain_strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
in = fopen(argv[1], "rb");
|
||||
if(in == NULL)
|
||||
{
|
||||
fprintf(stderr,"Unable to open input file %s\n", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
out = fopen(argv[2], "wb");
|
||||
if(out == NULL)
|
||||
{
|
||||
fclose(in);
|
||||
fprintf(stderr,"Unable to open output file %s\n", argv[2]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Seeking...\n");
|
||||
/* That condition is tricky... parentheses are crucial... */
|
||||
while((ret = mpg123_feedseek(m, 95000, SEEK_SET, &inoffset)) == MPG123_NEED_MORE)
|
||||
{
|
||||
len = fread(buf, sizeof(unsigned char), INBUFF, in);
|
||||
if(len <= 0)
|
||||
break;
|
||||
inc += len;
|
||||
|
||||
state = mpg123_feed(m, buf, len);
|
||||
if(state == MPG123_ERR)
|
||||
{
|
||||
fprintf(stderr, "Error: %s", mpg123_strerror(m));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if(ret == MPG123_ERR)
|
||||
{
|
||||
fprintf(stderr, "Feedseek failed: %s\n", mpg123_strerror(m));
|
||||
return -1;
|
||||
}
|
||||
|
||||
fseek(in, inoffset, SEEK_SET);
|
||||
|
||||
fprintf(stderr, "Starting decode...\n");
|
||||
while(1)
|
||||
{
|
||||
len = fread(buf, sizeof(unsigned char), INBUFF, in);
|
||||
if(len <= 0)
|
||||
break;
|
||||
inc += len;
|
||||
ret = mpg123_feed(m, buf, len);
|
||||
|
||||
while(ret != MPG123_ERR && ret != MPG123_NEED_MORE)
|
||||
{
|
||||
ret = mpg123_decode_frame(m, &num, &audio, &bytes);
|
||||
if(ret == MPG123_NEW_FORMAT)
|
||||
{
|
||||
mpg123_getformat(m, &rate, &channels, &enc);
|
||||
initwavformat();
|
||||
initwav();
|
||||
fprintf(stderr, "New format: %li Hz, %i channels, encoding value %i\n", rate, channels, enc);
|
||||
}
|
||||
fwrite(audio, sizeof(unsigned char), bytes, out);
|
||||
outc += bytes;
|
||||
}
|
||||
|
||||
if(ret == MPG123_ERR)
|
||||
{
|
||||
fprintf(stderr, "Error: %s", mpg123_strerror(m));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "Finished\n", (unsigned long)inc, (unsigned long)outc);
|
||||
|
||||
closewav();
|
||||
fclose(out);
|
||||
fclose(in);
|
||||
mpg123_delete(m);
|
||||
mpg123_exit();
|
||||
return 0;
|
||||
}
|
178
node_modules/lame/deps/mpg123/doc/examples/id3dump.c
generated
vendored
Normal file
178
node_modules/lame/deps/mpg123/doc/examples/id3dump.c
generated
vendored
Normal file
@ -0,0 +1,178 @@
|
||||
/*
|
||||
id3dump: Print ID3 tags of files, scanned using libmpg123.
|
||||
|
||||
copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1
|
||||
see COPYING and AUTHORS files in distribution or http://mpg123.org
|
||||
initially written by Thomas Orgis
|
||||
*/
|
||||
|
||||
#include "mpg123.h"
|
||||
#include <string.h>
|
||||
#include "stdio.h"
|
||||
#include "sys/types.h"
|
||||
|
||||
/* Helper for v1 printing, get these strings their zero byte. */
|
||||
void safe_print(char* name, char *data, size_t size)
|
||||
{
|
||||
char safe[31];
|
||||
if(size>30) return;
|
||||
|
||||
memcpy(safe, data, size);
|
||||
safe[size] = 0;
|
||||
printf("%s: %s\n", name, safe);
|
||||
}
|
||||
|
||||
/* Print out ID3v1 info. */
|
||||
void print_v1(mpg123_id3v1 *v1)
|
||||
{
|
||||
safe_print("Title", v1->title, sizeof(v1->title));
|
||||
safe_print("Artist", v1->artist, sizeof(v1->artist));
|
||||
safe_print("Album", v1->album, sizeof(v1->album));
|
||||
safe_print("Year", v1->year, sizeof(v1->year));
|
||||
safe_print("Comment", v1->comment, sizeof(v1->comment));
|
||||
printf("Genre: %i", v1->genre);
|
||||
}
|
||||
|
||||
/* Split up a number of lines separated by \n, \r, both or just zero byte
|
||||
and print out each line with specified prefix. */
|
||||
void print_lines(const char* prefix, mpg123_string *inlines)
|
||||
{
|
||||
size_t i;
|
||||
int hadcr = 0, hadlf = 0;
|
||||
char *lines = NULL;
|
||||
char *line = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
if(inlines != NULL && inlines->fill)
|
||||
{
|
||||
lines = inlines->p;
|
||||
len = inlines->fill;
|
||||
}
|
||||
else return;
|
||||
|
||||
line = lines;
|
||||
for(i=0; i<len; ++i)
|
||||
{
|
||||
if(lines[i] == '\n' || lines[i] == '\r' || lines[i] == 0)
|
||||
{
|
||||
char save = lines[i]; /* saving, changing, restoring a byte in the data */
|
||||
if(save == '\n') ++hadlf;
|
||||
if(save == '\r') ++hadcr;
|
||||
if((hadcr || hadlf) && hadlf % 2 == 0 && hadcr % 2 == 0) line = "";
|
||||
|
||||
if(line)
|
||||
{
|
||||
lines[i] = 0;
|
||||
printf("%s%s\n", prefix, line);
|
||||
line = NULL;
|
||||
lines[i] = save;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hadlf = hadcr = 0;
|
||||
if(line == NULL) line = lines+i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Print out the named ID3v2 fields. */
|
||||
void print_v2(mpg123_id3v2 *v2)
|
||||
{
|
||||
print_lines("Title: ", v2->title);
|
||||
print_lines("Artist: ", v2->artist);
|
||||
print_lines("Album: ", v2->album);
|
||||
print_lines("Year: ", v2->year);
|
||||
print_lines("Comment: ", v2->comment);
|
||||
print_lines("Genre: ", v2->genre);
|
||||
}
|
||||
|
||||
/* Print out all stored ID3v2 fields with their 4-character IDs. */
|
||||
void print_raw_v2(mpg123_id3v2 *v2)
|
||||
{
|
||||
size_t i;
|
||||
for(i=0; i<v2->texts; ++i)
|
||||
{
|
||||
char id[5];
|
||||
char lang[4];
|
||||
memcpy(id, v2->text[i].id, 4);
|
||||
id[4] = 0;
|
||||
memcpy(lang, v2->text[i].lang, 3);
|
||||
lang[3] = 0;
|
||||
if(v2->text[i].description.fill)
|
||||
printf("%s language(%s) description(%s)\n", id, lang, v2->text[i].description.p);
|
||||
else printf("%s language(%s)\n", id, lang);
|
||||
|
||||
print_lines(" ", &v2->text[i].text);
|
||||
}
|
||||
for(i=0; i<v2->extras; ++i)
|
||||
{
|
||||
char id[5];
|
||||
memcpy(id, v2->extra[i].id, 4);
|
||||
id[4] = 0;
|
||||
printf( "%s description(%s)\n",
|
||||
id,
|
||||
v2->extra[i].description.fill ? v2->extra[i].description.p : "" );
|
||||
print_lines(" ", &v2->extra[i].text);
|
||||
}
|
||||
for(i=0; i<v2->comments; ++i)
|
||||
{
|
||||
char id[5];
|
||||
char lang[4];
|
||||
memcpy(id, v2->comment_list[i].id, 4);
|
||||
id[4] = 0;
|
||||
memcpy(lang, v2->comment_list[i].lang, 3);
|
||||
lang[3] = 0;
|
||||
printf( "%s description(%s) language(%s): \n",
|
||||
id,
|
||||
v2->comment_list[i].description.fill ? v2->comment_list[i].description.p : "",
|
||||
lang );
|
||||
print_lines(" ", &v2->comment_list[i].text);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
mpg123_handle* m;
|
||||
if(argc < 2)
|
||||
{
|
||||
fprintf(stderr, "\nI will print some ID3 tag fields of MPEG audio files.\n");
|
||||
fprintf(stderr, "\nUsage: %s <mpeg audio file list>\n\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
mpg123_init();
|
||||
m = mpg123_new(NULL, NULL);
|
||||
|
||||
for(i=1; i < argc; ++i)
|
||||
{
|
||||
mpg123_id3v1 *v1;
|
||||
mpg123_id3v2 *v2;
|
||||
int meta;
|
||||
if(mpg123_open(m, argv[i]) != MPG123_OK)
|
||||
{
|
||||
fprintf(stderr, "Cannot open %s: %s\n", argv[i], mpg123_strerror(m));
|
||||
continue;
|
||||
}
|
||||
mpg123_scan(m);
|
||||
meta = mpg123_meta_check(m);
|
||||
if(meta & MPG123_ID3 && mpg123_id3(m, &v1, &v2) == MPG123_OK)
|
||||
{
|
||||
printf("Tag data on %s:\n", argv[i]);
|
||||
printf("\n==== ID3v1 ====\n");
|
||||
if(v1 != NULL) print_v1(v1);
|
||||
|
||||
printf("\n==== ID3v2 ====\n");
|
||||
if(v2 != NULL) print_v2(v2);
|
||||
|
||||
printf("\n==== ID3v2 Raw frames ====\n");
|
||||
if(v2 != NULL) print_raw_v2(v2);
|
||||
}
|
||||
else printf("Nothing found for %s.\n", argv[i]);
|
||||
|
||||
mpg123_close(m);
|
||||
}
|
||||
mpg123_delete(m);
|
||||
mpg123_exit();
|
||||
return 0;
|
||||
}
|
118
node_modules/lame/deps/mpg123/doc/examples/mpg123_to_wav.c
generated
vendored
Normal file
118
node_modules/lame/deps/mpg123/doc/examples/mpg123_to_wav.c
generated
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
mpg123_to_wav.c
|
||||
|
||||
copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1
|
||||
see COPYING and AUTHORS files in distribution or http://mpg123.org
|
||||
initially written by Nicholas Humfrey
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <strings.h>
|
||||
#include <mpg123.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
|
||||
void usage()
|
||||
{
|
||||
printf("Usage: mpg123_to_wav <input> <output> [s16|f32 [ <buffersize>]]\n");
|
||||
exit(99);
|
||||
}
|
||||
|
||||
void cleanup(mpg123_handle *mh)
|
||||
{
|
||||
/* It's really to late for error checks here;-) */
|
||||
mpg123_close(mh);
|
||||
mpg123_delete(mh);
|
||||
mpg123_exit();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SNDFILE* sndfile = NULL;
|
||||
SF_INFO sfinfo;
|
||||
mpg123_handle *mh = NULL;
|
||||
unsigned char* buffer = NULL;
|
||||
size_t buffer_size = 0;
|
||||
size_t done = 0;
|
||||
int channels = 0, encoding = 0;
|
||||
long rate = 0;
|
||||
int err = MPG123_OK;
|
||||
off_t samples = 0;
|
||||
|
||||
if (argc<3) usage();
|
||||
printf( "Input file: %s\n", argv[1]);
|
||||
printf( "Output file: %s\n", argv[2]);
|
||||
|
||||
err = mpg123_init();
|
||||
if(err != MPG123_OK || (mh = mpg123_new(NULL, &err)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Basic setup goes wrong: %s", mpg123_plain_strerror(err));
|
||||
cleanup(mh);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Simple hack to enable floating point output. */
|
||||
if(argc >= 4 && !strcmp(argv[3], "f32")) mpg123_param(mh, MPG123_ADD_FLAGS, MPG123_FORCE_FLOAT, 0.);
|
||||
|
||||
/* Let mpg123 work with the file, that excludes MPG123_NEED_MORE messages. */
|
||||
if( mpg123_open(mh, argv[1]) != MPG123_OK
|
||||
/* Peek into track and get first output format. */
|
||||
|| mpg123_getformat(mh, &rate, &channels, &encoding) != MPG123_OK )
|
||||
{
|
||||
fprintf( stderr, "Trouble with mpg123: %s\n", mpg123_strerror(mh) );
|
||||
cleanup(mh);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(encoding != MPG123_ENC_SIGNED_16 && encoding != MPG123_ENC_FLOAT_32)
|
||||
{ /* Signed 16 is the default output format anyways; it would actually by only different if we forced it.
|
||||
So this check is here just for this explanation. */
|
||||
cleanup(mh);
|
||||
fprintf(stderr, "Bad encoding: 0x%x!\n", encoding);
|
||||
return -2;
|
||||
}
|
||||
/* Ensure that this output format will not change (it could, when we allow it). */
|
||||
mpg123_format_none(mh);
|
||||
mpg123_format(mh, rate, channels, encoding);
|
||||
|
||||
bzero(&sfinfo, sizeof(sfinfo) );
|
||||
sfinfo.samplerate = rate;
|
||||
sfinfo.channels = channels;
|
||||
sfinfo.format = SF_FORMAT_WAV|(encoding == MPG123_ENC_SIGNED_16 ? SF_FORMAT_PCM_16 : SF_FORMAT_FLOAT);
|
||||
printf("Creating WAV with %i channels and %liHz.\n", channels, rate);
|
||||
|
||||
sndfile = sf_open(argv[2], SFM_WRITE, &sfinfo);
|
||||
if(sndfile == NULL){ fprintf(stderr, "Cannot open output file!\n"); cleanup(mh); return -2; }
|
||||
|
||||
/* Buffer could be almost any size here, mpg123_outblock() is just some recommendation.
|
||||
Important, especially for sndfile writing, is that the size is a multiple of sample size. */
|
||||
buffer_size = argc >= 5 ? atol(argv[4]) : mpg123_outblock(mh);
|
||||
buffer = malloc( buffer_size );
|
||||
|
||||
do
|
||||
{
|
||||
sf_count_t more_samples;
|
||||
err = mpg123_read( mh, buffer, buffer_size, &done );
|
||||
more_samples = encoding == MPG123_ENC_SIGNED_16
|
||||
? sf_write_short(sndfile, (short*)buffer, done/sizeof(short))
|
||||
: sf_write_float(sndfile, (float*)buffer, done/sizeof(float));
|
||||
if(more_samples < 0 || more_samples*mpg123_encsize(encoding) != done)
|
||||
{
|
||||
fprintf(stderr, "Warning: Written number of samples does not match the byte count we got from libmpg123: %li != %li\n", (long)(more_samples*mpg123_encsize(encoding)), (long)done);
|
||||
}
|
||||
samples += more_samples;
|
||||
/* We are not in feeder mode, so MPG123_OK, MPG123_ERR and MPG123_NEW_FORMAT are the only possibilities.
|
||||
We do not handle a new format, MPG123_DONE is the end... so abort on anything not MPG123_OK. */
|
||||
} while (err==MPG123_OK);
|
||||
|
||||
if(err != MPG123_DONE)
|
||||
fprintf( stderr, "Warning: Decoding ended prematurely because: %s\n",
|
||||
err == MPG123_ERR ? mpg123_strerror(mh) : mpg123_plain_strerror(err) );
|
||||
|
||||
sf_close( sndfile );
|
||||
|
||||
samples /= channels;
|
||||
printf("%li samples written.\n", (long)samples);
|
||||
cleanup(mh);
|
||||
return 0;
|
||||
}
|
92
node_modules/lame/deps/mpg123/doc/examples/mpglib.c
generated
vendored
Normal file
92
node_modules/lame/deps/mpg123/doc/examples/mpglib.c
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
mpglib: test program for libmpg123, in the style of the legacy mpglib test program
|
||||
|
||||
copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1
|
||||
see COPYING and AUTHORS files in distribution or http://mpg123.org
|
||||
initially written by Thomas Orgis
|
||||
*/
|
||||
|
||||
#include <mpg123.h>
|
||||
|
||||
/* unistd.h is not available under MSVC,
|
||||
io.h defines the read and write functions */
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define INBUFF 16384
|
||||
#define OUTBUFF 32768
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
size_t size;
|
||||
unsigned char buf[INBUFF]; /* input buffer */
|
||||
unsigned char out[OUTBUFF]; /* output buffer */
|
||||
ssize_t len;
|
||||
int ret;
|
||||
size_t in = 0, outc = 0;
|
||||
mpg123_handle *m;
|
||||
|
||||
#ifdef _WIN32
|
||||
_setmode(_fileno(stdin),_O_BINARY);
|
||||
_setmode(_fileno(stdout),_O_BINARY);
|
||||
#endif
|
||||
|
||||
mpg123_init();
|
||||
m = mpg123_new(argc > 1 ? argv[1] : NULL, &ret);
|
||||
if(m == NULL)
|
||||
{
|
||||
fprintf(stderr,"Unable to create mpg123 handle: %s\n", mpg123_plain_strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
mpg123_param(m, MPG123_VERBOSE, 2, 0); /* Brabble a bit about the parsing/decoding. */
|
||||
|
||||
/* Now mpg123 is being prepared for feeding. The main loop will read chunks from stdin and feed them to mpg123;
|
||||
then take decoded data as available to write to stdout. */
|
||||
mpg123_open_feed(m);
|
||||
if(m == NULL) return -1;
|
||||
|
||||
fprintf(stderr, "Feed me some MPEG audio to stdin, I will decode to stdout.\n");
|
||||
while(1) /* Read and write until everything is through. */
|
||||
{
|
||||
len = read(0,buf,INBUFF);
|
||||
if(len <= 0)
|
||||
{
|
||||
fprintf(stderr, "input data end\n");
|
||||
break;
|
||||
}
|
||||
in += len;
|
||||
/* Feed input chunk and get first chunk of decoded audio. */
|
||||
ret = mpg123_decode(m,buf,len,out,OUTBUFF,&size);
|
||||
if(ret == MPG123_NEW_FORMAT)
|
||||
{
|
||||
long rate;
|
||||
int channels, enc;
|
||||
mpg123_getformat(m, &rate, &channels, &enc);
|
||||
fprintf(stderr, "New format: %li Hz, %i channels, encoding value %i\n", rate, channels, enc);
|
||||
}
|
||||
write(1,out,size);
|
||||
outc += size;
|
||||
while(ret != MPG123_ERR && ret != MPG123_NEED_MORE)
|
||||
{ /* Get all decoded audio that is available now before feeding more input. */
|
||||
ret = mpg123_decode(m,NULL,0,out,OUTBUFF,&size);
|
||||
write(1,out,size);
|
||||
outc += size;
|
||||
}
|
||||
if(ret == MPG123_ERR){ fprintf(stderr, "some error: %s", mpg123_strerror(m)); break; }
|
||||
}
|
||||
fprintf(stderr, "%lu bytes in, %lu bytes out\n", (unsigned long)in, (unsigned long)outc);
|
||||
|
||||
/* Done decoding, now just clean up and leave. */
|
||||
mpg123_delete(m);
|
||||
mpg123_exit();
|
||||
return 0;
|
||||
}
|
47
node_modules/lame/deps/mpg123/doc/examples/scan.c
generated
vendored
Normal file
47
node_modules/lame/deps/mpg123/doc/examples/scan.c
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
scan: Estimate length (sample count) of a mpeg file and compare to length from exact scan.
|
||||
|
||||
copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1
|
||||
see COPYING and AUTHORS files in distribution or http://mpg123.org
|
||||
initially written by Thomas Orgis
|
||||
*/
|
||||
|
||||
/* Note the lack of error checking here.
|
||||
While it would be nicer to inform the user about troubles, libmpg123 is designed _not_ to bite you on operations with invalid handles , etc.
|
||||
You just jet invalid results on invalid operations... */
|
||||
|
||||
#include <mpg123.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
mpg123_handle *m;
|
||||
int i;
|
||||
if(argc < 2)
|
||||
{
|
||||
fprintf(stderr, "\nI will give you the estimated and exact sample lengths of MPEG audio files.\n");
|
||||
fprintf(stderr, "\nUsage: %s <mpeg audio file list>\n\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
mpg123_init();
|
||||
m = mpg123_new(NULL, NULL);
|
||||
mpg123_param(m, MPG123_RESYNC_LIMIT, -1, 0); /* New in library version 0.0.1 . */
|
||||
for(i = 1; i < argc; ++i)
|
||||
{
|
||||
off_t a, b;
|
||||
|
||||
mpg123_open(m, argv[i]);
|
||||
|
||||
a = mpg123_length(m);
|
||||
mpg123_scan(m);
|
||||
b = mpg123_length(m);
|
||||
|
||||
mpg123_close(m);
|
||||
|
||||
printf("File %i: estimated %li vs. scanned %li\n", i, (long)a, (long)b);
|
||||
}
|
||||
|
||||
mpg123_delete(m);
|
||||
mpg123_exit();
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user