Ejemplo n.º 1
0
/*--------------------------------------------------------------------------------*/
bool ADMRIFFFile::CreateExtraChunks()
{
  bool success = true;

  if (adm)
  {
    RIFFChunk *chunk;
    uint64_t  chnalen;
    uint8_t   *chna;
    uint_t i, nchannels = GetChannels();

    success = true;

    for (i = 0; i < nchannels; i++)
    {
      ADMAudioTrack *track;

      // create chna track data
      if ((track = adm->CreateTrack(i)) != NULL)
      {
        track->SetSampleRate(GetSampleRate());
        track->SetBitDepth(GetBitsPerSample());
      }
    }

    if (!admfile.empty())
    {
      // create ADM structure (content and objects from file)
      if (adm->CreateFromFile(admfile.c_str()))
      {
        // can prepare cursors now since all objects have been created
        PrepareCursors();
      }
      else
      {
        BBCERROR("Unable to create ADM structure from '%s'", admfile.c_str());
        success = false;
      }
    }

    // get ADM object to create chna chunk
    if ((chna = adm->GetChna(chnalen)) != NULL)
    {
      // and add it to the RIFF file
      if ((chunk = AddChunk(chna_ID)) != NULL)
      {
        success &= chunk->CreateChunkData(chna, chnalen);
      }
      else BBCERROR("Failed to add chna chunk");

      // don't need the raw data any more
      delete[] chna;
    }
    else BBCERROR("No chna data available");

    success &= (AddChunk(axml_ID) != NULL);
  }

  return success;
}
Ejemplo n.º 2
0
/*--------------------------------------------------------------------------------*/
void ADMRIFFFile::SetObjectParameters(uint_t channel, const AudioObjectParameters& objparameters)
{
  // create cursors if necessary and add all objects to them
  PrepareCursors();

  if (writing && (channel < cursors.size()))
  {
    PERFMON("Write ADM Channel Parameters");
    uint64_t t = filesamples ? filesamples->GetAbsolutePositionNS() : 0;

    cursors[channel]->Seek(t);
    cursors[channel]->SetObjectParameters(objparameters);
  }
}