Thanks. 

I found C sources that use MikMod to compute the time of a module and
it seems to be extremely fast

It's part of MikMod Utilities (mmu) on SourceForge
http://sourceforge.net/projects/mmu


Code:
--------------------
    
  static int execute(int argc, char **argv) {
  MODULE *module = NULL;
  unsigned long total_time = 0;
  int total_files = 0;
  int i;
  
  for (i = 0; i < argc; i++)
  file_list_append(file_list, argv[i]);
  
  if (!file_list->length) {
  ERROR_MSG("no modules specified");
  print_usage(stderr);
  return EX_USAGE;
  }
  
  md_device = 0;
  md_mixfreq = LOW_QUALITY_MIXFREQ;
  md_mode = LOW_QUALITY_MODE;
  
  MikMod_RegisterDriver(&drv_nos);
  MikMod_RegisterAllLoaders();
  
  if (MikMod_Init("")) {
  ERROR_MSG("could not init MikMod: %s",
  MikMod_strerror(MikMod_errno));
  return EX_SOFTWARE;
  }
  
  for (i = 0; i < file_list->length; i++) {
  module = module_load(file_list_item(file_list, i),
  LOW_QUALITY_MAXCHAN, 0);
  if (module == NULL) continue;
  total_time += module_get_time(module);
  total_files++;
  Player_Free(module);
  if (progress)
  print_progress(total_time, total_files,
  file_list->length);
  }
  
  MikMod_Exit();
  
  print_result(total_time, total_files);
  
  return total_files ? EX_OK : mmu_status;
  }
  
--------------------


Which is pretty much what I'm trying to do in perl. They too are using
the drv_nos. So I have hope that it'll be fast enough in perl if we can
use it as well. finger crossed.

I temporarily recompiled my libmikmod without alsa and oss support so
it doesn't try to load real sound drivers (only file out and stdout
left). Now MikMod_Init () works and I experimented with unpack to try
to grab the song title from the $module variable but all I got so far
was segmentation faults or garbage data :-( I guess trying to unpack a
C structure is not a good topic to start perl programming :-P


Code:
--------------------
    
  print "module = before unpack\n";
  my ($songnameptr, $trackerptr, $commentptr) = unpack "LLL", $module;
  print "module = after unpack\n";
  
  if ( defined $songnameptr) {
  my $songname = pack( "p", $songnameptr);
  $tags->{'TITLE'} = $songname;
  print (unpack "p", $songname);
  print "\n$songname\n";
  }
  if (defined $commentptr) {
  my $comment = pack( "p", $commentptr);
  $tags->{'COMMENT'} = $comment;
  print (unpack "p", $comment);
  print "\n$comment\n";
  }
  
--------------------


The first three members of the C module structure are char * to song
title, song comment and tracker version.

Any advice from perl guru greatly appreciated.

-WildCoder


-- 
WildCoder
------------------------------------------------------------------------
WildCoder's Profile: http://forums.slimdevices.com/member.php?userid=1827
View this thread: http://forums.slimdevices.com/showthread.php?t=17845

_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/lists/listinfo/unix

Reply via email to