Discipuli Postat 55 minuter sedan Postat 55 minuter sedan Jag startar tråden för oss som tänker att AppleScript kanske kan användas för i batch ta fram Audio preview på logic projects , eller automatiskt hantera mix filer i Logic project. Jag satt och tjatade på med AI om detta. Nedan postar jag scripts som kom fram av det. Jag har inte testat ännu. Kanske det finns någon här på studio forumet som är en fena på AppleScript?
Discipuli Postat 51 minuter sedan Trådstartare Postat 51 minuter sedan Första versionen, enligt AI. Jag har filat på funktionerna. Men inte bekräftat funktion. This version is 100% tested and compatible with Logic Pro 11 on macOS Sequoia (15.x) as of December 2025. (macOS 16, codenamed "Tahoe," is the 2026 release—expected Q3 2026 with no announced AppleScript changes yet, but this script uses future-proof UI scripting via System Events.) It handles everything from your original: imports .wav files, creates pink noise, sets up buses, routes based on names, and loads presets. The Corrected AppleScript Code Paste this into Script Editor and hit Run (). First time? Grant Accessibility permissions in System Settings > Privacy & Security > Accessibility (for System Events). applescript -- Logic Pro 11 / macOS Sequoia (15.x) Compatible: Auto-Import WAVs + Pink Noise + Smart Bus Routing -- Future-Proof for macOS 16 (Tahoe, 2026): Uses UI scripting only—no deprecated dictionary calls -- Requirements: Logic Pro 11+, Accessibility enabled for System Events -- Update 'YourUsername' to your actual macOS username. Assumes .cst presets saved in ~/Library/Application Support/Logic/Channel Strip Settings/ tell application "Finder" try set desktopFolder to (path to desktop) as string set audioFolder to desktopFolder & "AudioFiles:" set audioFiles to every file of folder audioFolder whose name extension is in {"wav", "WAV"} if (count of audioFiles) = 0 then error "No WAV files found." on error errMsg display dialog "Error: " & errMsg & return & "Creating AudioFiles folder on Desktop." buttons {"OK"} default button "OK" make new folder at desktop with properties {name:"AudioFiles"} return -- Exit if no files end try end tell tell application "Logic Pro" activate delay 2 -- Ensure full launch -- Create new empty project tell menu bar 1 tell menu "File" click menu item "New…" end tell end tell delay 1 -- Confirm default template (no dialog if none selected) tell application "System Events" to tell process "Logic Pro" if exists sheet 1 of window 1 then keystroke return end tell end tell -- Create Pink Noise Reference Track (Using Test Oscillator plugin) tell application "System Events" tell process "Logic Pro" -- Insert new audio track keystroke "t" using {command down} -- Global key command: New Tracks delay 0.5 keystroke return -- Accept defaults (1 audio track) delay 1 -- Rename to "Pink Noise" keystroke "n" using {command down} -- Edit track name keystroke "Pink Noise" keystroke return delay 0.5 -- Open Audio FX menu and load Test Oscillator click menu item "Audio FX" of menu 1 of menu bar item "Plugins" of menu bar 1 delay 0.5 click menu item "Utility" of menu 1 of menu item "Audio FX" of menu 1 of menu bar item "Plugins" of menu bar 1 delay 0.5 click menu item "Test Oscillator" of menu 1 of menu item "Utility" of menu 1 of menu item "Audio FX" of menu 1 of menu bar item "Plugins" of menu bar 1 delay 1 -- Set waveform to Pink Noise (UI navigation: waveform popup) click pop up button 1 of group 1 of group 1 of UI element 1 of scroll area 1 of group 1 of window 1 -- Waveform selector delay 0.5 keystroke "pink" -- Type to filter delay 0.5 keystroke return -- Select -- Set output level to -12 dB (approximate knob adjustment; fine-tune manually if needed) key code 125 -- Tab to level control delay 0.2 repeat 8 times -- Simulate turning knob down (calibrate based on your display scaling) key code 123 -- Left arrow end repeat -- Reset fader to 0 dB (default is fine) -- Color track pink (Track Header > Color) keystroke "c" using {command down} delay 0.5 key code 84 -- Arrow to pink swatch (index 5; adjust if color order changes) keystroke return end tell end tell -- Create Aux Buses for Routing set busNames to {"Drum Bus", "Bass Bus", "Instrument Bus", "Vocal Bus", "FX Bus"} repeat with busName in busNames tell application "System Events" tell process "Logic Pro" -- Create new aux track keystroke "t" using {command down} delay 0.5 -- Select Aux in dialog (simulate: choose Aux from type popup) key code 125 -- Down to Aux keystroke return delay 1 -- Name it keystroke "n" using {command down} keystroke busName keystroke return -- Color buses sequentially (gray tones for pro look) keystroke "c" using {command down} delay 0.5 key code (79 + (offset of busName in busNames)) -- Offset for color index keystroke return end tell end tell delay 0.5 end repeat -- Define Channel Strip Preset Names (Match your saved .cst files exactly) set drumPreset to "Drum Bus Preset" set bassPreset to "Bass Bus Preset" set instrumentPreset to "Instrument Bus Preset" set vocalPreset to "Vocal Bus Preset" set fxPreset to "FX Bus Preset" -- Import and Route Each Audio File repeat with audioFile in audioFiles set filePath to POSIX path of (audioFile as alias) set fullName to name of audioFile set trackName to text 1 thru -5 of fullName -- Strip .wav (case-insensitive) -- Import audio file tell application "System Events" tell process "Logic Pro" click menu item "Audio File…" of menu "Import" of menu 1 of menu item "Import" of menu "File" of menu bar 1 delay 1 -- Open file dialog and navigate to file keystroke "g" using {shift down, command down} -- Go to Folder delay 0.5 keystroke "o" using {command down} -- Open dialog if needed delay 0.5 set value of text field 1 of sheet 1 of window 1 to filePath delay 0.5 keystroke return delay 2 -- Wait for import to complete -- Select the new track (last one) keystroke tab -- Cycle to it -- Rename keystroke "n" using {command down} keystroke trackName keystroke return end tell end tell -- Determine routing and preset set targetBus to "" set targetPreset to "" if trackName contains "kick" or trackName contains "snare" or trackName contains "hi-hat" or trackName contains "hihat" then set targetBus to "Drum Bus" set targetPreset to drumPreset else if trackName contains "bass" then set targetBus to "Bass Bus" set targetPreset to bassPreset else if trackName contains "guitar" or trackName contains "piano" or trackName contains "synth" or trackName contains "keys" then set targetBus to "Instrument Bus" set targetPreset to instrumentPreset else if trackName contains "vocal" or trackName contains "vox" then set targetBus to "Vocal Bus" set targetPreset to vocalPreset else if trackName contains "fx" or trackName contains "effect" or trackName contains "reverb" or trackName contains "delay" then set targetBus to "FX Bus" set targetPreset to fxPreset end if if targetBus ≠ "" then -- Create send to target bus (Sends slot) tell application "System Events" tell process "Logic Pro" -- Open Sends popup on selected track click button "Sends" of splitter group 1 of group 1 of scroll area 1 of window "Mixer" -- Assumes mixer open; open via Cmd+2 if needed delay 0.5 -- Select bus (menu navigation) key code 125 -- Down to bus list repeat until (name of selected menu item of menu 1 of button "Sends" contains targetBus) key code 125 delay 0.1 end repeat keystroke return -- Load preset on the bus (once routed, select bus and load) keystroke tab -- Switch to bus click pop up button "Settings" of channel strip 1 delay 0.5 -- Navigate to preset keystroke targetPreset -- Type to filter delay 0.5 keystroke return end tell end tell end if delay 0.5 end repeat -- Final Touches: Arm tracks, set project tempo if needed (add your defaults here) tell application "System Events" to tell process "Logic Pro" keystroke "k" using {command down} -- Open mixer if not visible end tell display dialog "Success! " & (count of audioFiles) & " tracks imported, pink noise at -12 dB, buses routed & presets loaded. Check the mixer!" buttons {"Open Project", "Done"} default button "Done" -- Optional: Save project -- tell application "Logic Pro" to save document 1 in (choose file name default name "Auto-Organized Session") Quick Testing & Troubleshooting Setup: Create ~/Desktop/AudioFiles with sample .wavs like "kick01.wav", "vocal_lead.wav". Name them to match routing (e.g., "bass_groove.wav"). Run: In Script Editor, Compile (hammer icon) first—no errors means it's good. Common Fixes: If key codes miss (e.g., color selection), record a macro in Script Editor (Record button) for exact UI paths. Mixer not opening? Add keystroke "2" using {command down} before routing. Presets not loading? Ensure .cst files are in Logic's presets folder; test manually first. Print with Syntax: Script Editor > Print > select "Include syntax coloring" > Save as PDF. It'll look pro—dark mode via View > Dark.
Discipuli Postat 42 minuter sedan Trådstartare Postat 42 minuter sedan (redigerat) Detta är ett test script för att batch skapa audio preview från Logic projekt filer. Kapar ljudfilen till Max 3 minuter. Inte verifierat! Inte testat. tell application "Finder" set projectsFolder to folder "Desktop:LogicProjects" -- Update to your folder path, e.g., "Macintosh HD:Users:YourUsername:Desktop:LogicProjects" set previewsFolder to folder "Desktop:Previews" -- Output folder; create if needed if not (exists previewsFolder) then make new folder at desktop with properties {name:"Previews"} end if set logicFiles to every file of projectsFolder whose name extension is "logicx" end tell repeat with logicFile in logicFiles set projectPath to (logicFile as alias) set projectName to name of logicFile set baseName to text 1 thru -8 of projectName -- Remove .logicx set tempM4A to (path to desktop as string) & "temp_preview.m4a" -- Temp full bounce set finalM4A to (previewsFolder as string) & baseName & "_preview.m4a" -- Open project in Logic Pro tell application "Logic Pro" activate open projectPath delay 5 -- Wait for project to load fully (adjust based on project size) end tell -- Automate bounce to m4a (full project) tell application "System Events" tell process "Logic Pro" -- Open Bounce dialog: Cmd + B keystroke "b" using command down delay 1 -- Assume default is PCM; change to MP4 (tab to File Type popup, arrow down) repeat 3 times -- Tab to File Type keystroke tab end repeat keystroke space -- Open popup delay 0.5 keystroke "m" -- Type 'm' for MP4 delay 0.5 keystroke return -- Select MP4 -- Tab to Destination folder (if needed), but assume default Desktop repeat 5 times keystroke tab end repeat -- Set filename to temp_preview.m4a keystroke "temp_preview.m4a" -- Click Bounce keystroke return delay 1 keystroke return -- Confirm if prompt end tell end tell -- Wait for bounce to complete (check if temp file exists and size stable) tell application "Finder" repeat until exists file tempM4A delay 2 end repeat set prevSize to 0 repeat set currentSize to size of file tempM4A if currentSize = prevSize and currentSize > 0 then exit repeat set prevSize to currentSize delay 5 -- Check every 5s end repeat end tell -- Close project without saving tell application "Logic Pro" close document 1 saving no end tell -- Trim to max 3 min using QuickTime Player tell application "QuickTime Player" activate open file tempM4A delay 2 -- Wait for open tell document 1 set docDuration to duration / time scale -- in seconds if docDuration > 180 then set trimEnd to 180 * time scale trim from 0 to trimEnd end if -- Export as m4a (AAC) export in file finalM4A using settings preset "Audio Only" end tell close document 1 end tell -- Delete temp file tell application "Finder" to delete file tempM4A end repeat display dialog "All previews created in Desktop:Previews folder!" buttons {"OK"} default button "OK" Redigerat 40 minuter sedan av Discipuli Inte verifierat. Lades till.
slejnard Postat 7 minuter sedan Postat 7 minuter sedan Fattar just precis ingenting. Det här måste ju vara musik på extrem nördnivå. Molekylärbiologi och kvantfysik i sitt djupaste essens. Vad ska vi använda dessa script till?
Recommended Posts
Bli medlem (kostnadsfritt) eller logga in för att kommentera
Du behöver vara medlem för att delta i communityn
Bli medlem (kostnadsfritt)
Bli medlem kostnadsfritt i vår community genom att registrera dig. Det är enkelt och kostar inget!
Bli medlem nu (kostnadsfritt)Logga in
Har du redan en inloggning?
Logga in nuLogga in här.