Newsgroup: it.comp.os.linux.sys
Titolo: o.t. manipolare mp3.

Scusate per l'o.t.
Uso la debian 2.2 e il programma GQmpeg per ascolate .mp3.
Volevo sapere se c'e' la possibilita', e come, per manipolare questi files
con qualche programma.
Per esempio vorrei accellerarli in modo da sollevare la tonalita'
di mezzo tono.
Grazie.
-- 

On 28 Jan 2001 00:17:51 GMT, Mauro Sanna was talkin' about :

Molte funzioni simpatiche sono presenti nella libmpeg3.
--
  	Giuseppe "Cowo" Corbelli  -->>  Riding on Linux-2.2.16
    **ANTI-SPAM** -- **Substitute IHATESPAM with cowo to reply by mail**
  -<! 3rd Law of Computing: Anything that can go wr
		fortune: Segmentation violation -- Core dumped !>-

Molte funzioni simpatiche sono presenti nella libmpeg3.
Nella debian 2.2 non me la ritrovo tra i pacchetti.
Potresti darmi un esempio del suo utilizzo?
Scusami ma sono a digiuno.
Grazie.
-- 

Potresti darmi un esempio del suo utilizzo?
Qui saremmo un po' OT...
la trovi cercando su freshmeat, dev'essere 
heroine.linuxave.net
La documentazione e' scarsissima.
Questa e' una semplice funzione di decodifica su file: usa anche libsndfile
e pingutil
/*return 0 if failure, 1 if OK*/
int decode_mp3 (char* inpath, char* outpath)    {
  short *bufr, *bufl, *temp;
  int srate, res, nstreams, nchannels;
  register int lindex, rindex, sindex;
  long nsamples;
  mpeg3_t* mp3fd;
  SF_INFO *wavdesc;
  SNDFILE *outfile;
 
/* Buffer to contain mixed right and left channel */
  temp =(short *)P_mem_manage (NULL, sizeof (short)*CHUNK, 1, 1, TRUE);
/* Right channel, half the capacity of temp */
  bufr =(short *)P_mem_manage (NULL, CHUNK, 1, 1, TRUE);
/* Left channel, half the capacity of temp */
  bufl =(short *)P_mem_manage (NULL, CHUNK, 1, 1, TRUE);
/* libsndfile structures */
  wavdesc =(SF_INFO *)P_mem_manage (NULL, sizeof (SF_INFO), 1, 1, TRUE);
  outfile =(SNDFILE *)P_mem_manage (NULL, sizeof (SNDFILE), 1, 1, TRUE);
  mp3fd =(mpeg3_t *)P_mem_manage (NULL, sizeof (mpeg3_t), 1, 1, TRUE);
 
  if (!mpeg3_check_sig (inpath))  {
    P_error_printf ("Not compatible MPEG stream\n");
    return (EXIT_FAILURE);
  }
 
  if ( !(mp3fd = mpeg3_open(inpath)) )    {
    P_error_printf ("Cannot open source file %s\n", inpath);
    return (EXIT_FAILURE);
  }
  if (!mpeg3_has_audio (mp3fd))   {
    P_error_printf ("No audio in MPEG file.\n");
    return (EXIT_FAILURE);
  }
  if ( (nstreams = mpeg3_total_astreams (mp3fd)) != 1)    {
    P_error_printf ("Sorry, unsupported number of streams: %d\n", nstreams);
    return (EXIT_FAILURE);
  }
  if ( (nchannels = mpeg3_audio_channels (mp3fd, 0)) != 2) {
    P_error_printf ("Sorry, unsupported number of channels: %d\n", nchannels);
    return (EXIT_FAILURE);
  }
  nsamples = mpeg3_audio_samples (mp3fd, 0);
  srate = mpeg3_sample_rate (mp3fd, 0);
  if (srate != 44100)     {
    P_error_printf ("Sorry, CD-DA needs 44100 hz samplerate\n");
    return (EXIT_FAILURE);
  }
  wavdesc->samplerate = srate;
  wavdesc->channels = nchannels;
  wavdesc->pcmbitwidth = 16;
  wavdesc->format = SF_FORMAT_WAV|SF_FORMAT_PCM;
 
/* Rewind stream */
  mpeg3_set_sample (mp3fd, 0, 0);
 
  if ( !(outfile=sf_open_write(outpath, wavdesc)))        {
    P_error_printf ("Error while opening write file\n");
    return (EXIT_FAILURE);
  }
 
  do      {
    if ( ((res = mpeg3_read_audio (mp3fd, NULL, bufr, RIGHT_CHANNEL, CHUNK/2,
       0)) != 0) || ((res = mpeg3_reread_audio (mp3fd, NULL, bufl,
         LEFT_CHANNEL, CHUNK/2, 0)) != 0) )      {
 
      P_error_printf ("Error decoding audio\n");
      return (EXIT_FAILURE);
    }
    progress_callback (nsamples, mpeg3_get_sample (mp3fd, 0));
    rindex=0;
    lindex=1;
    sindex=0;
    while ( (rindex < CHUNK) && (lindex < CHUNK) && (sindex < CHUNK/2) )    { 
      memcpy ((short *)temp+(rindex*sizeof(short)), 
               (short *)bufr+(sindex*sizeof(short)), sizeof (short));           
 
      memcpy ((short *)temp+(lindex*sizeof(short)), (short
           *)bufl+(sindex*sizeof(short)), sizeof (short));
      rindex+=sizeof(short);
      lindex+=sizeof(short);
      sindex++;
    }                       
    if ( (sf_write_short (outfile, temp, CHUNK)) < CHUNK)   {
      P_error_printf ("Not enough bytes written!\n");
      return (EXIT_FAILURE);
    }
  } while ( !(mpeg3_end_of_audio(mp3fd, 0)));
  mpeg3_close (mp3fd);
  sf_close (outfile);
  return (EXIT_SUCCESS);
}
--
  	Giuseppe "Cowo" Corbelli  -->>  Riding on Linux-2.2.16
    **ANTI-SPAM** -- **Substitute IHATESPAM with cowo to reply by mail**
  -<! Take It All, Our Gold, Our Homes, Our Life, 
  		But We Didn't Kill Your Christ! !>-
  			Blind Guardian - The Script For My Requiem