Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.89 KB | None | 0 0
  1. for (size_t t = 0; t < p_composition->trackCount(); ++t) {
  2.                             Track &track = p_composition->track(t);
  3.                             if (track.type() == TrackType::Audio) {
  4.                                
  5.                                 for(int i=0;i<track.channels() && i < 2;i++){
  6.                                     IAAFSequence *sequence = nullptr;
  7.                                     dictionary->CreateInstance(AUID_AAFSequence, IID_IAAFSequence, reinterpret_cast<IUnknown**>(&sequence));
  8.  
  9.                                     IAAFSegment *segment = nullptr;
  10.                                     sequence->QueryInterface(IID_IAAFSegment, reinterpret_cast<void**>(&segment));
  11.                                     sequence->Initialize(sounddatadef);
  12.  
  13.                                     IAAFTimelineMobSlot *slot = nullptr;
  14.                                     aafRational_t rate = {48000, 1};
  15.  
  16.                                     // set track name
  17.                                     aafCharacter name[256];
  18.                                     size_t len = strlen(track.name().c_str());
  19.                                     len = MultiByteToWideChar(0, 0, track.name().c_str(), len, name, 253);
  20.                                     name[len++] = L'_';
  21.                                     name[len++] = i?L'R':L'L';
  22.                                     name[len] = L'\0';
  23.                                    
  24.                                     mob->AppendNewTimelineSlot(rate, segment, tc++, name, 0, &slot);
  25.                                     IAAFMobSlot *mobslot = nullptr;
  26.                                     slot->QueryInterface(IID_IAAFMobSlot, reinterpret_cast<void**>(&mobslot));
  27.                                     if (mobslot) {
  28.                                         mobslot->SetPhysicalNum(i + 1);
  29.                                         mobslot->Release();
  30.                                     }
  31.  
  32.                                     TimeValue currentpos = 0;
  33.                                     for (size_t c = 0; c < track.clipCount(); ++c) {
  34.                                         const Clip &clip = track.clip(c);
  35.  
  36.                                         // insert filler if there's space between last clip end
  37.                                         // and current clip start
  38.                                         if (clip.position() > currentpos) {
  39.                                             IAAFComponent *filler = nullptr;
  40.                                             dictionary->CreateInstance(AUID_AAFFiller, IID_IAAFComponent, reinterpret_cast<IUnknown**>(&filler));
  41.                                             filler->SetDataDef(sounddatadef);
  42.                                             filler->SetLength(48 * (tempo.msecs(clip.position()) - tempo.msecs(currentpos)));
  43.  
  44.                                             sequence->AppendComponent(filler);
  45.  
  46.                                             filler->Release();
  47.  
  48.                                             currentpos = clip.position();
  49.                                         }
  50.  
  51.                                         // insert clip (ignore automation for now)
  52.                                         IAAFSourceClip *sourceclip = nullptr;
  53.                                         dictionary->CreateInstance(AUID_AAFSourceClip, IID_IAAFSourceClip, reinterpret_cast<IUnknown**>(&sourceclip));
  54.  
  55.                                         if (clip.source()) {
  56.                                             auto s = sources.find(clip.source());
  57.                                             if (s != sources.end()) {
  58.                                                 aafSourceRef_t ref;
  59.                                                 ref.sourceID = i?s->second.Rid:s->second.Lid;
  60.                                                 ref.sourceSlotID = 1;
  61.                                                 ref.startTime = 48*tempo.msecs(clip.start());
  62.                                                 sourceclip->Initialize(sounddatadef, 48 * (tempo.msecs(clip.end()) - tempo.msecs(clip.start())), ref);
  63.                                             }
  64.                                         }
  65.  
  66.                                         IAAFComponent *comp = nullptr;
  67.                                         sourceclip->QueryInterface(IID_IAAFComponent, reinterpret_cast<void**>(&comp));
  68.                                         sequence->AppendComponent(comp);
  69.  
  70.                                         comp->Release();
  71.                                         sourceclip->Release();
  72.  
  73.                                         currentpos += clip.end() - clip.start();
  74.                                     }
  75.  
  76.                                     sequence->Release();
  77.                                     segment->Release();
  78.                                     slot->Release();
  79.                                 }
  80.                             }
  81.                         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement