Esempio n. 1
0
static FS_EncDec *
fs_encdec_new (int format, int blocksize)
{
  FS_EncDec * ed;
  FishSoundInfo fsinfo;

  ed = malloc (sizeof (FS_EncDec));

  fsinfo.samplerate = 8000;
  fsinfo.channels = 1;
  fsinfo.format = format;

  ed->encoder = fish_sound_new (FISH_SOUND_ENCODE, &fsinfo);
  ed->decoder = fish_sound_new (FISH_SOUND_DECODE, &fsinfo);

  fish_sound_set_interleave (ed->encoder, 1);
  fish_sound_set_interleave (ed->decoder, 1);

  fish_sound_set_encoded_callback (ed->encoder, encoded, ed);
  fish_sound_set_decoded_callback (ed->decoder, decoded, ed);
  
  ed->pcm = (float **) malloc (sizeof (float) * blocksize);
  fs_fill_square ((float *)ed->pcm, blocksize);

  return ed;
}
Esempio n. 2
0
int play (char * file, char ** opts) {
 OGGZ * oggz;
 struct roarfish_play_inst inst;

 inst.roarfh = -1;
 inst.begun  = 0;

 inst.fsound = fish_sound_new(FISH_SOUND_DECODE, &inst.fsinfo);
 fish_sound_set_interleave(inst.fsound, 1);

 fish_sound_set_decoded_float_ilv(inst.fsound, decoded_float, (void*)&inst);

 if ((oggz = oggz_open(file, OGGZ_READ)) == NULL) {
  ROAR_ERR("Can not open input file: %s", file);
  return -1;
 }

 oggz_set_read_callback(oggz, -1, read_packet, inst.fsound);

 // TODO: add some status display here?
 while (oggz_read(oggz, 1024));

 oggz_close(oggz);

 fish_sound_delete(inst.fsound);

 return -1;
}
Esempio n. 3
0
static int
decoded (FishSound * fsound, float ** pcm, long frames, void * user_data)
{
  FS_DecEnc * ed = (FS_DecEnc *) user_data;
  FishSoundInfo fsinfo;
  int i;

  if (!ed->begun) {
    fish_sound_command (fsound, FISH_SOUND_GET_INFO, &fsinfo,
			sizeof (FishSoundInfo));

    fsinfo.format = ed->format;
    ed->encoder = fish_sound_new (FISH_SOUND_ENCODE, &fsinfo);
    fish_sound_set_interleave (ed->encoder, ed->interleave);
    fish_sound_set_encoded_callback (ed->encoder, encoded, ed);

    ed->channels = fsinfo.channels;
    if (ed->interleave) {
      ed->pcm = (float **) malloc (sizeof (float) * ed->channels * ed->blocksize);
    } else {
      ed->pcm = (float **) malloc (sizeof (float *) * ed->channels);
      for (i = 0; i < ed->channels; i++) {
        ed->pcm[i] = (float *) malloc (sizeof (float) * ed->blocksize);
      }
    }

    ed->begun = 1;
  }

  fish_sound_encode (ed->encoder, pcm, frames);

  return 0;
}
Esempio n. 4
0
static int input_init(input_t * self, PyObject * args, PyObject * kwds){

  self->output = NULL;
  self->outlen = -1;

  FishSoundInfo info;

  info.samplerate = SAMP_RATE;
  info.channels = CHANS;
  info.format = FISH_SOUND_SPEEX;

  self->decoder = fish_sound_new(FISH_SOUND_DECODE,&info);
  
  if(self->decoder == NULL) return -1;

  return 0;

}
Esempio n. 5
0
static FS_DecEnc *
fs_encdec_new (char * infilename, char * outfilename, int format,
	       int interleave, int blocksize)
{
  FS_DecEnc * ed;

  if (infilename == NULL || outfilename == NULL) return NULL;

  ed = malloc (sizeof (FS_DecEnc));

  ed->infilename = strdup (infilename);
  ed->outfilename = strdup (outfilename);

  ed->oggz_in = oggz_open (infilename, OGGZ_READ);
  ed->oggz_out = oggz_open (outfilename, OGGZ_WRITE);

  oggz_set_read_callback (ed->oggz_in, -1, read_packet, ed);
  ed->serialno = oggz_serialno_new (ed->oggz_out);

  ed->decoder = fish_sound_new (FISH_SOUND_DECODE, NULL);

  fish_sound_set_interleave (ed->decoder, interleave);

  fish_sound_set_decoded_float_ilv (ed->decoder, decoded, ed);

  ed->format = format;
  ed->interleave = interleave;
  ed->blocksize = blocksize;
  ed->begun = 0;
  ed->b_o_s = 1;

  /* Delay the setting of channels and allocation of PCM buffers until
   * the number of channels is known from decoding the headers */
  ed->channels = 0;
  ed->pcm = NULL;

  ed->frames_in = 0;
  ed->frames_out = 0;

  return ed;
}
Esempio n. 6
0
OggVorbisReadStream::OggVorbisReadStream(QString path) :
    m_path(path),
    m_d(new D(this))
{
    m_channelCount = 0;
    m_sampleRate = 0;

    if (!(m_d->m_oggz = oggz_open(path.toLocal8Bit().data(), OGGZ_READ))) {
	m_error = QString("File \"%1\" is not an OGG file.").arg(path);
	return;
    }

    FishSoundInfo fsinfo;
    m_d->m_fishSound = fish_sound_new(FISH_SOUND_DECODE, &fsinfo);

    fish_sound_set_decoded_callback(m_d->m_fishSound, D::acceptFramesStatic, m_d);
    oggz_set_read_callback(m_d->m_oggz, -1, D::acceptPacketStatic, m_d);

    // initialise m_channelCount
    while (m_channelCount == 0 && !m_d->m_finished) {
        m_d->readNextBlock(); 
    }
}
Esempio n. 7
0
static OMX_ERRORTYPE init_vorbis_decoder (vorbisd_prc_t *ap_prc)
{
  OMX_ERRORTYPE rc = OMX_ErrorInsufficientResources;

  assert (NULL != ap_prc);

  tiz_check_null_ret_oom (
      ap_prc->p_fsnd_ = fish_sound_new (FISH_SOUND_DECODE, &(ap_prc->fsinfo_)));

  if (0 != fish_sound_set_interleave (ap_prc->p_fsnd_, 1))
    {
      TIZ_ERROR (handleOf (ap_prc),
                 "[OMX_ErrorInsufficientResources] : "
                 "Could not set interleaved.");
      goto end;
    }

  if (0 != fish_sound_set_decoded_float_ilv (
               ap_prc->p_fsnd_, fishsound_decoded_callback, ap_prc))
    {
      TIZ_ERROR (handleOf (ap_prc),
                 "[OMX_ErrorInsufficientResources] : "
                 "Could not set 'decoded' callback.");
      goto end;
    }

  rc = OMX_ErrorNone;

end:
  if (OMX_ErrorInsufficientResources == rc)
    {
      fish_sound_delete (ap_prc->p_fsnd_);
      ap_prc->p_fsnd_ = NULL;
    }

  return rc;
}
Esempio n. 8
0
int
main (int argc, char * argv[])
{
  FishSoundInfo fsinfo;
  const FishSoundComment * comment, * comment2;
  FishSoundComment mycomment;
  int err;

  fsinfo.samplerate = 16000;
  fsinfo.channels = 1;
  /* The format doesn't really matter as we're not actually
   * going to encode any audio, so just ensure we can
   * set this to something that's configured.
   */
#if HAVE_VORBIS
  fsinfo.format = FISH_SOUND_VORBIS;
#elif HAVE_SPEEX
  fsinfo.format = FISH_SOUND_SPEEX;
#else
  fsinfo.format = FISH_SOUND_FLAC;
#endif

#if FS_ENCODE
  INFO ("Initializing FishSound for comments (encode)");
  fsound = fish_sound_new (FISH_SOUND_ENCODE, &fsinfo);

  INFO ("+ Adding ARTIST1 byname");
  err = fish_sound_comment_add_byname (fsound, "ARTIST", ARTIST1);
  if (err < 0) FAIL ("Operation failed");

  INFO ("+ Adding COPYRIGHT byname");
  err = fish_sound_comment_add_byname (fsound, "COPYRIGHT", COPYRIGHT);
  if (err < 0) FAIL ("Operation failed");

  INFO ("+ Retrieving first (expect ARTIST1)");
  comment = fish_sound_comment_first (fsound);

  if (comment == NULL)
    FAIL ("Recently inserted ARTIST1 not retrieved");

  if (strcmp (comment->name, "ARTIST"))
    FAIL ("Incorrect ARTIST1 name found");

  if (strcmp (comment->value, ARTIST1))
    FAIL ("Incorrect ARTIST1 value found");

  INFO ("+ Retrieving next (expect COPYRIGHT)");
  comment = fish_sound_comment_next (fsound, comment);

  if (comment == NULL)
    FAIL ("Recently inserted COPYRIGHT not retrieved");

  if (strcmp (comment->name, "COPYRIGHT"))
    FAIL ("Incorrect COPYRIGHT name found");

  if (strcmp (comment->value, COPYRIGHT))
    FAIL ("Incorrect COPYRIGHT value found");

  INFO ("+ Checking comments termination");
  comment2 = fish_sound_comment_next (fsound, comment);

  if (comment2 != NULL)
    FAIL ("Comments unterminated");

  INFO ("+ Adding LICENSE from local storage");
  mycomment.name = "LICENSE";
  mycomment.value = LICENSE;
  err = fish_sound_comment_add (fsound, &mycomment);
  if (err < 0) FAIL ("Operation failed");

  INFO ("+ Retrieving next (expect LICENSE)");
  comment = fish_sound_comment_next (fsound, comment);

  if (comment == NULL)
    FAIL ("Recently inserted LICENSE not retrieved");

  if (comment == &mycomment)
    FAIL ("Recently inserted LICENSE not restored");

  if (strcmp (comment->name, "LICENSE"))
    FAIL ("Incorrect LICENSE name found");

  if (strcmp (comment->value, LICENSE))
    FAIL ("Incorrect LICENSE value found");

  INFO ("+ Testing add of valid plain (not key=value) COMMENT byname");
  err = fish_sound_comment_add_byname (fsound, COMMENT, NULL);
  if (err < 0) FAIL ("Operation failed");

  INFO ("+ Testing add of valid plain (not key=value) COMMENT from local storage");
  mycomment.name = COMMENT;
  mycomment.value = NULL;
  err = fish_sound_comment_add (fsound, &mycomment);
  if (err < 0) FAIL ("Operation failed");

  INFO ("+ Adding ARTIST2 byname");  
  err = fish_sound_comment_add_byname (fsound, "ARTIST", ARTIST2);
  if (err < 0) FAIL ("Operation failed");

  INFO ("+ Retrieving first ARTIST using wierd caps (expect ARTIST1)");
  comment = fish_sound_comment_first_byname (fsound, "ArTiSt");

  if (comment == NULL)
    FAIL ("Recently inserted ARTIST1 not retrieved");

  if (strcmp (comment->name, "ARTIST"))
    FAIL ("Incorrect ARTIST1 name found");

  if (strcmp (comment->value, ARTIST1))
    FAIL ("Incorrect ARTIST1 value found");

  INFO ("+ Retrieving next ARTIST (expect ARTIST2)");
  comment = fish_sound_comment_next_byname (fsound, comment);

  if (comment == NULL)
    FAIL ("Recently inserted ARTIST2 not retrieved");

  if (strcmp (comment->name, "ARTIST"))
    FAIL ("Incorrect ARTIST2 name found");

  if (strcmp (comment->value, ARTIST2))
    FAIL ("Incorrect ARTIST2 value found");

  INFO ("+ Removing LICENSE byname");
  err = fish_sound_comment_remove_byname (fsound, "LICENSE");
  if (err != 1) FAIL ("Operation failed");

  INFO ("+ Attempting to retrieve LICENSE");
  comment = fish_sound_comment_first_byname (fsound, "LICENSE");

  if (comment != NULL)
    FAIL ("Removed comment incorrectly retrieved");

  INFO ("+ Removing COPYRIGHT from local storage");
  mycomment.name = "COPYRIGHT";
  mycomment.value = COPYRIGHT;
  err = fish_sound_comment_remove (fsound, &mycomment);
  if (err != 1) FAIL ("Operation failed");

  INFO ("+ Attempting to retrieve COPYRIGHT");
  comment = fish_sound_comment_first_byname (fsound, "COPYRIGHT");

  if (comment != NULL)
    FAIL ("Removed comment incorrectly retrieved");

  INFO ("Deleting FishSound (encode)");
  fish_sound_delete (fsound);
#endif /* FS_ENCODE */

#if FS_DECODE
  INFO ("Initializing FishSound for comments (decode)");
  fsound = fish_sound_new (FISH_SOUND_DECODE, &fsinfo);

  INFO ("+ Adding ARTIST1 byname (invalid for decode)");
  err = fish_sound_comment_add_byname (fsound, "ARTIST", ARTIST1);

  if (err == 0)
    FAIL ("Operation disallowed");

  INFO ("+ Removing ARTIST byname (invalid for decode)");
  err = fish_sound_comment_remove_byname (fsound, "ARTIST");

  if (err == 0)
    FAIL ("Operation disallowed");

  INFO ("Deleteing FishSound (decode)");
  fish_sound_delete (fsound);
#endif

  exit (0);
}