Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Diff for Pan Presets for the Blender VSE
diff --git a/release/scripts/startup/bl_operators/sequencer.py b/release/scripts/startup/bl_operators/sequencer.py
index 48a02a4c5c6..b94d2f03709 100644
--- a/release/scripts/startup/bl_operators/sequencer.py
+++ b/release/scripts/startup/bl_operators/sequencer.py
@@ -377,10 +377,138 @@ def calculate_duration_frames(context, duration_seconds):
return round(duration_seconds * context.scene.render.fps / context.scene.render.fps_base)
+class SEQUENCER_OT_pan_presets(Operator):
+ """Pan Presets"""
+ bl_idname = "sequencer.pan_presets"
+ bl_label = "Pan Preset"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ mono: EnumProperty(
+ items=(
+ ('NONE', 'None', 'None avalible'),
+ ),
+ name="Mono Presets",
+ description="Mono Presets",
+ default='NONE')
+
+ stereo: EnumProperty(
+ items=(
+ ('LEFT', 'Left', 'Pan to the left'),
+ ('CENTER', 'Center', 'Pan to the center'),
+ ('RIGHT', 'Right', 'Pan to the right'),
+ ),
+ name="Stereo Presets",
+ description="Pan the audio",
+ default='CENTER')
+
+ surround4: EnumProperty(
+ items=(
+ ('FRONTLEFT', 'Front Left', 'Pan to the left'),
+ ('FRONTCENTER', 'Front Center', 'Pan to the center'),
+ ('FRONTRIGHT', 'Front Right', 'Pan to the right'),
+ ('SIDELEFT', 'Side Left', 'Pan to the side left'),
+ ('SIDERIGHT', 'Side Right', 'Pan to the side right'),
+ ),
+ name="4 Channel Presets",
+ description="Pan the audio",
+ default='FRONTCENTER')
+
+ surround51: EnumProperty(
+ items=(
+ ('FRONTLEFT', 'Front Left', 'Pan to the front left'),
+ ('FRONTCENTER', 'Front Center', 'Pan to the front center'),
+ ('FRONTRIGHT', 'Front Right', 'Pan to the front right'),
+ ('SIDELEFT', 'Side Left', 'Pan to the side left'),
+ ('SIDERIGHT', 'Side Right', 'Pan to the side right'),
+ ),
+ name="5.1 Surround Presets",
+ description="Pan the audio",
+ default='FRONTCENTER')
+
+ surround71: EnumProperty(
+ items=(
+ ('FRONTLEFT', 'Front Left', 'Pan to the front left'),
+ ('FRONTCENTER', 'Front Center', 'Pan to the front center'),
+ ('FRONTRIGHT', 'Front Right', 'Pan to the front right'),
+ ('SIDELEFT', 'Side Left', 'Pan to the side left'),
+ ('SIDERIGHT', 'Side Right', 'Pan to the side right'),
+ ('REARLEFT', 'Rear Left', 'Pan to the rear left'),
+ ('REARRIGHT', 'Rear Right', 'Pan to the rear right'),
+ ),
+ name="7.1 Surround Presets",
+ description="Pan the audio",
+ default='FRONTCENTER')
+
+ @classmethod
+ def poll(cls, context):
+ # Can't use context.selected_sequences as it can have an impact on performances
+ return context.scene and context.scene.sequence_editor and context.scene.sequence_editor.active_strip
+
+ def execute(self, context):
+ audio_channels = context.preferences.system.audio_channels
+ sequences = context.selected_sequences
+
+ if not sequences:
+ sequences = context.scene.sequence_editor.active_strip
+ for sequence in sequences:
+ if audio_channels == 'STEREO':
+ if self.stereo == 'LEFT':
+ sequence.pan = -1.0
+ if self.stereo == 'CENTER':
+ sequence.pan = 0.0
+ if self.stereo == 'RIGHT':
+ sequence.pan = 1.0
+
+ if audio_channels == 'SURROUND4':
+ if self.surround4 == 'FRONTLEFT':
+ sequence.pan = -0.5
+ if self.surround4 == 'FRONTCENTER':
+ sequence.pan = 0
+ if self.surround4 == 'FRONTRIGHT':
+ sequence.pan = 0.5
+
+ if self.surround4 == 'SIDELEFT':
+ sequence.pan = -1.5
+ if self.surround4 == 'SIDERIGHT':
+ sequence.pan = 1.5
+
+ if audio_channels == 'SURROUND51':
+ if self.surround51 == 'FRONTLEFT':
+ sequence.pan = -0.33335
+ if self.surround51 == 'FRONTCENTER':
+ sequence.pan = 0
+ if self.surround51 == 'FRONTRIGHT':
+ sequence.pan = 0.33335
+
+ if self.surround51 == 'SIDELEFT':
+ sequence.pan = -1.2225
+ if self.surround51 == 'SIDERIGHT':
+ sequence.pan = 1.2225
+
+ if audio_channels == 'SURROUND71':
+ if self.surround71 == 'FRONTLEFT':
+ sequence.pan = -0.33335
+ if self.surround71 == 'FRONTCENTER':
+ sequence.pan = 0
+ if self.surround71 == 'FRONTRIGHT':
+ sequence.pan = 0.33335
+
+ if self.surround71 == 'SIDELEFT':
+ sequence.pan = -1.2225
+ if self.surround71 == 'SIDERIGHT':
+ sequence.pan = 1.2225
+
+ if self.surround71 == 'REARLEFT':
+ sequence.pan = -1.66667
+ if self.surround71 == 'REARRIGHT':
+ sequence.pan = 1.66667
+ return {'FINISHED'}
+
classes = (
SequencerCrossfadeSounds,
SequencerSplitMulticam,
SequencerDeinterlaceSelectedMovies,
SequencerFadesClear,
SequencerFadesAdd,
+ SEQUENCER_OT_pan_presets,
)
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 55714e0b0a5..74d6758340f 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -1672,6 +1672,8 @@ class SEQUENCER_PT_adjust_sound(SequencerButtonsPanel, Panel):
return strip.type == 'SOUND'
def draw(self, context):
+ audio_channels = context.preferences.system.audio_channels
+ audio_channels = audio_channels.lower()
layout = self.layout
layout.use_property_split = True
@@ -1686,15 +1688,27 @@ class SEQUENCER_PT_adjust_sound(SequencerButtonsPanel, Panel):
col.prop(strip, "volume", text="Volume")
col.prop(strip, "pitch")
+ col = layout.column(heading="Mono")
+ col.prop(sound, "use_mono", text="")
+
col = layout.column()
+
col.prop(strip, "pan")
- col.enabled = sound is not None and sound.use_mono
+ split = col.split(factor=0.37)
+ split.alignment = 'RIGHT'
+ split.label(text="Pan Preset")
+ # Get enum text.
+ prefs = context.preferences
+ enum_def = prefs.system.bl_rna.properties["audio_channels"]
+ lut = {i.identifier: i.name for i in enum_def.enum_items}
+ split.operator_menu_enum(
+ 'sequencer.pan_presets', audio_channels, text=lut[prefs.system.audio_channels])
+ col.enabled = split.enabled = sound is not None and sound.use_mono
if sound is not None:
- col = layout.column()
+ col = layout.column(heading="Display")
if st.waveform_display_type == 'DEFAULT_WAVEFORMS':
- col.prop(strip, "show_waveform")
- col.prop(sound, "use_mono")
+ col.prop(strip, "show_waveform", text="Waveform")
class SEQUENCER_PT_adjust_comp(SequencerButtonsPanel, Panel):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment