Sha256: de492b2f1515b01f6679dcb61322e9287e17308ed797d302f4a02c8b48a0303d
Contents?: true
Size: 1.65 KB
Versions: 4
Compression:
Stored size: 1.65 KB
Contents
#include <stdio.h> #include <ctype.h> #include <string.h> #include <mpcdec/mpcdec.h> #include <ruby.h> #include "mppdec.h" #include "id3tag.h" static VALUE mMpc; static VALUE cInfo; static VALUE rb_mpc_info(VALUE module, VALUE filename); void Init_mpc() { mMpc = rb_define_module("Mpc"); cInfo = rb_define_class_under(mMpc, "Info", rb_cObject); int i = 0; //#define NA 5 const char *attr2[] = { "time", "bps","sample_rate", "channels", "bits_per_sample", "comments","tracknumber","year","title","artist","album","comment",NULL }; for (i = 0; attr2[i]; i++) { rb_define_attr(cInfo, attr2[i], 1, 0); } rb_define_module_function(mMpc, "info", rb_mpc_info, 1); } VALUE rb_mpc_info(VALUE self, VALUE filename) { VALUE info = rb_class_new_instance(0, NULL, cInfo); mpc_reader_file r; mpc_streaminfo si; TagInfo_t tags; FILE *fp=fopen(STR2CSTR(filename),"r"); mpc_streaminfo_init(&si); mpc_reader_setup_file_reader(&r,fp); mpc_streaminfo_read(&si,&r.reader); rb_iv_set(info,"@time",rb_float_new(mpc_streaminfo_get_length(&si))); rb_iv_set(info,"@sample_rate",INT2FIX(si.sample_freq)); rb_iv_set(info,"@channels",INT2FIX(si.channels)); rb_iv_set(info,"@bps",rb_float_new(si.average_bitrate)); Read_APE_Tags(fp,&tags); rb_iv_set(info,"@tracknumber",rb_str_new2(tags.Track)); rb_iv_set(info,"@year",rb_str_new2(tags.Year)); rb_iv_set(info,"@title",rb_str_new2(tags.Title)); rb_iv_set(info,"@artist",rb_str_new2(tags.Artist)); rb_iv_set(info,"@album",rb_str_new2(tags.Album)); rb_iv_set(info,"@comment",rb_str_new2(tags.Comment)); fclose(fp); return info; }
Version data entries
4 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
catori-0.2.5 | ./ext/mpc/mpc.c |
catori-0.2.5 | ext/mpc/mpc.c |
catori-0.2.6 | ./ext/mpc/mpc.c |
catori-0.2.6 | ext/mpc/mpc.c |