Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (size_t t = 0; t < p_composition->trackCount(); ++t) {
- Track &track = p_composition->track(t);
- if (track.type() == TrackType::Audio) {
- for(int i=0;i<track.channels() && i < 2;i++){
- IAAFSequence *sequence = nullptr;
- dictionary->CreateInstance(AUID_AAFSequence, IID_IAAFSequence, reinterpret_cast<IUnknown**>(&sequence));
- IAAFSegment *segment = nullptr;
- sequence->QueryInterface(IID_IAAFSegment, reinterpret_cast<void**>(&segment));
- sequence->Initialize(sounddatadef);
- IAAFTimelineMobSlot *slot = nullptr;
- aafRational_t rate = {48000, 1};
- // set track name
- aafCharacter name[256];
- size_t len = strlen(track.name().c_str());
- len = MultiByteToWideChar(0, 0, track.name().c_str(), len, name, 253);
- name[len++] = L'_';
- name[len++] = i?L'R':L'L';
- name[len] = L'\0';
- mob->AppendNewTimelineSlot(rate, segment, tc++, name, 0, &slot);
- IAAFMobSlot *mobslot = nullptr;
- slot->QueryInterface(IID_IAAFMobSlot, reinterpret_cast<void**>(&mobslot));
- if (mobslot) {
- mobslot->SetPhysicalNum(i + 1);
- mobslot->Release();
- }
- TimeValue currentpos = 0;
- for (size_t c = 0; c < track.clipCount(); ++c) {
- const Clip &clip = track.clip(c);
- // insert filler if there's space between last clip end
- // and current clip start
- if (clip.position() > currentpos) {
- IAAFComponent *filler = nullptr;
- dictionary->CreateInstance(AUID_AAFFiller, IID_IAAFComponent, reinterpret_cast<IUnknown**>(&filler));
- filler->SetDataDef(sounddatadef);
- filler->SetLength(48 * (tempo.msecs(clip.position()) - tempo.msecs(currentpos)));
- sequence->AppendComponent(filler);
- filler->Release();
- currentpos = clip.position();
- }
- // insert clip (ignore automation for now)
- IAAFSourceClip *sourceclip = nullptr;
- dictionary->CreateInstance(AUID_AAFSourceClip, IID_IAAFSourceClip, reinterpret_cast<IUnknown**>(&sourceclip));
- if (clip.source()) {
- auto s = sources.find(clip.source());
- if (s != sources.end()) {
- aafSourceRef_t ref;
- ref.sourceID = i?s->second.Rid:s->second.Lid;
- ref.sourceSlotID = 1;
- ref.startTime = 48*tempo.msecs(clip.start());
- sourceclip->Initialize(sounddatadef, 48 * (tempo.msecs(clip.end()) - tempo.msecs(clip.start())), ref);
- }
- }
- IAAFComponent *comp = nullptr;
- sourceclip->QueryInterface(IID_IAAFComponent, reinterpret_cast<void**>(&comp));
- sequence->AppendComponent(comp);
- comp->Release();
- sourceclip->Release();
- currentpos += clip.end() - clip.start();
- }
- sequence->Release();
- segment->Release();
- slot->Release();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement