@@ -1937,6 +1937,76 @@ def test_aaf_writer_global_start_time(self):
1937
1937
1938
1938
self ._verify_aaf (tmp_aaf_path )
1939
1939
1940
+ def test_aaf_writer_audio_pan (self ):
1941
+ """Test Clip with custom audio pan values"""
1942
+ tl = otio .schema .Timeline ()
1943
+
1944
+ # Add an audio clip with pan metadata
1945
+ clip = otio .schema .Clip (
1946
+ name = "Panned Audio Clip" ,
1947
+ metadata = {},
1948
+ source_range = otio .opentime .TimeRange (
1949
+ start_time = otio .opentime .RationalTime (0 , 24 ),
1950
+ duration = otio .opentime .RationalTime (100 , 24 ),
1951
+ )
1952
+ )
1953
+ clip .media_reference = otio .schema .MissingReference (
1954
+ available_range = otio .opentime .TimeRange (
1955
+ start_time = otio .opentime .RationalTime (0 , 24 ),
1956
+ duration = otio .opentime .RationalTime (100 , 24 ),
1957
+ ))
1958
+
1959
+ # Add pan metadata
1960
+ clip .metadata ["AAF" ] = {
1961
+ "Pan" : {
1962
+ "ControlPoints" : [
1963
+ {
1964
+ "ControlPointSource" : 2 ,
1965
+ "Time" : "0" ,
1966
+ "Value" : "0" ,
1967
+ },
1968
+ {
1969
+ "ControlPointSource" : 2 ,
1970
+ "Time" : "100" ,
1971
+ "Value" : "1" ,
1972
+ }
1973
+ ]
1974
+ },
1975
+ "SourceID" : "urn:smpte:umid:060a2b34.01010101.01010f00."
1976
+ "13000000.060e2b34.7f7f2a80.5c9e6a3b.ace913a2"
1977
+ }
1978
+
1979
+ tl .tracks .append (
1980
+ otio .schema .Track (children = [clip ], kind = otio .schema .TrackKind .Audio )
1981
+ )
1982
+
1983
+ _ , tmp_aaf_path = tempfile .mkstemp (suffix = '.aaf' )
1984
+ otio .adapters .write_to_file (tl , tmp_aaf_path )
1985
+ print (tmp_aaf_path )
1986
+
1987
+ # verify pan values in AAF file
1988
+ with aaf2 .open (tmp_aaf_path ) as aaf_file :
1989
+ mob = next (aaf_file .content .compositionmobs ())
1990
+ slot = mob .slots [0 ]
1991
+ parameter = list (slot .segment .parameters )[0 ]
1992
+
1993
+ # extract the pan values
1994
+ param_dicts = [
1995
+ {k : v .value for k , v in dict (p ).items ()}
1996
+ for p in parameter .pointlist
1997
+ ]
1998
+
1999
+ expected = [
2000
+ {'ControlPointSource' : 2 ,
2001
+ 'Time' : aaf2 .rational .AAFRational (0 , 1 ),
2002
+ 'Value' : aaf2 .rational .AAFRational (0 , 1 )},
2003
+ {'ControlPointSource' : 2 ,
2004
+ 'Time' : aaf2 .rational .AAFRational (100 , 1 ),
2005
+ 'Value' : aaf2 .rational .AAFRational (1 , 1 )}
2006
+ ]
2007
+
2008
+ self .assertEqual (param_dicts , expected )
2009
+
1940
2010
def _verify_aaf (self , aaf_path ):
1941
2011
otio_timeline = otio .adapters .read_from_file (aaf_path , simplify = True )
1942
2012
fd , tmp_aaf_path = tempfile .mkstemp (suffix = '.aaf' )
0 commit comments