Skip to main content
Inspiring
May 19, 2024
Question

ChatGPT4 can now write Extendscript and will give detailed instructions on packaging CEP extensions!

  • May 19, 2024
  • 1 reply
  • 940 views

Having been frustrated for years by the abject lack of documentation for Extendscript I find this to be phenominal. I just used it to create an extension for Audition (probably the least documented platform) that removes gaps between all clips in a miltitrack track. (Disclaimer: I have not tested this code, so there may be errors and it may not run at all.)

 

As I disclaimed, this code is untested and as yet hasn't been run in Audition. Even so, the fact that it has providd a good starting point is astounding considering the ¯\(°_o)/¯ attitude of Adobe concerining documentation of Extendscript and CEF extensions, particularly in reference to Audition. This is a shame because Audition could benefit from scripting almost as much as Photoshop or Premier Pro. I'll not go so far as saying that it can benefit as much as After Effects because, obviously, AE is incredibly complex.

 

This just blew my mind a little bit, so I had to share it. I have been trying to do this for years but the nearly complete lack of documentation for CEF/Extendscript (again, especially in Audition) has prohibited me from doing so. What documentation there is almost completely unhelpful bordering on useless. There are a few 3rd party sources, but Adobe seems to have just put the functionality in and then abandon it, at least insofar as documentation goes.

 

It is pretty ironic that ChatGPT, the cretors of Dall-e, which is a direct competitor to Firefly, are the ones that finlly enabled me to write a (hopefully) usable extension for Audition. I feel like Adobe should probably be a little bit ashamed of this fact. Maybe they can buy in to ChatGPT to write their documentation or something. 

 

If someone wants to check the code (etc, as it also provides instructions on packaging the extension), it is linked at the end of the first paragraph. If anyone finds needed corrections, please post them. Even if it is buggy AF, it is still more than Adobe has given me in the years I have wanted to do this very simple extension.

This topic has been closed for replies.

1 reply

AVLienAuthor
Inspiring
May 19, 2024

The entire output (for convenience and completeness):

Note: indentation was lost when transferring to the code blocks here.

To modify the script so that it can be run as an extension from a menu item in Adobe Audition, you'll need to package it as an Adobe CEP (Common Extensibility Platform) extension. This involves creating a few additional files and configuring the extension properly.

Here is a step-by-step guide:

 

1. Create the ExtendScript file (e.g., `removeGaps.jsx`):

 

// ExtendScript for Adobe Audition to remove all gaps between clips on the active track

// Function to remove gaps between clips on the active track
function removeGapsBetweenClipsOnActiveTrack() {
// Get the active project
var project = app.project;

// Check if there are any open projects
if (!project) {
alert("No project open.");
return;
}

// Get the active Multitrack session
var session = project.activeSession;

// Check if there is an active session
if (!session) {
alert("No active session.");
return;
}

// Get the active track
var activeTrack = session.activeTrack;

// Check if there is an active track
if (!activeTrack) {
alert("No active track selected.");
return;
}

// Get the number of clips in the active track
var clipCount = activeTrack.clips.length;

// Check if there are clips in the active track
if (clipCount < 2) {
alert("Not enough clips to remove gaps.");
return;
}

// Iterate through the clips and remove gaps
for (var i = 1; i < clipCount; i++) {
var prevClip = activeTrack.clips[i - 1];
var currentClip = activeTrack.clips[i];

// Calculate the gap between the previous clip and the current clip
var gap = currentClip.startTime - prevClip.endTime;

// If there is a gap, move the current clip to close the gap
if (gap > 0) {
currentClip.startTime -= gap;
}
}

alert("All gaps between clips on the active track have been removed.");
}

// Execute the function
removeGapsBetweenClipsOnActiveTrack();

 

```

2. Create an HTML file (e.g., `index.html`):

 

<!DOCTYPE html>
<html>
<head>
<title>Remove Gaps Extension</title>
<script>
function runScript() {
// Get the CSEvent and dispatch it to run the ExtendScript
var csInterface = new CSInterface();
csInterface.evalScript('$.evalFile("' + csInterface.getSystemPath(SystemPath.EXTENSION) + '/removeGaps.jsx")');
}
</script>
</head>
<body>
<button onclick="runScript()">Remove Gaps Between Clips</button>
</body>
</html>

 

 

3. Create a manifest file (e.g., `manifest.xml`):

 

<?xml version="1.0" encoding="UTF-8"?>
<ExtensionManifest Version="7.0" ExtensionBundleId="com.example.removegaps"
ExtensionBundleVersion="1.0.0" ExtensionBundleName="Remove Gaps Extension">
<ExtensionList>
<Extension Id="com.example.removegaps.extension" Version="1.0.0"/>
</ExtensionList>
<ExecutionEnvironment>
<HostList>
<Host Name="AUDT" Version="[13.0,99.9]"/>
</HostList>
<LocaleList>
<Locale Code="All"/>
</LocaleList>
<RequiredRuntimeList>
<RequiredRuntime Name="CSXS" Version="10.0"/>
</RequiredRuntimeList>
</ExecutionEnvironment>
<DispatchInfoList>
<Extension Id="com.example.removegaps.extension">
<DispatchInfo>
<Resources>
<MainPath>./index.html</MainPath>
<ScriptPath>./removeGaps.jsx</ScriptPath>
</Resources>
<Lifecycle>
<AutoVisible>true</AutoVisible>
</Lifecycle>
<UI>
<Type>Panel</Type>
<Menu>Remove Gaps</Menu>
<Geometry>
<Size>
<Height>100</Height>
<Width>300</Width>
</Size>
</Geometry>
</UI>
</DispatchInfo>
</Extension>
</DispatchInfoList>
</ExtensionManifest>

 

4. Create a `CSXS` folder and add `manifest.xml` inside it:

Directory structure:

your-extension-folder/
├── CSXS/
│ └── manifest.xml
├── index.html
└── removeGaps.jsx

5. Package the extension:
Zip the `your-extension-folder` and rename it to `your-extension-folder.zxp`.

6. Install the extension:

Use the `Adobe Extension Manager` or `ZXPInstaller` to install the `.zxp` package.

7. Run the extension in Adobe Audition:

Open Adobe Audition, navigate to `Window` > `Extensions`, and you should see your "Remove Gaps Extension." Clicking on it will open a panel with a button to run your ExtendScript.

 

By following these steps, you can create an extension for Adobe Audition that adds a menu item to remove gaps between clips on the active track.

SteveG_AudioMasters_
Community Expert
Community Expert
May 19, 2024

I agree entirely about the lack of any real guidance whatsoever regarding Extendscript, but having already had a run-in with ChatGPT regarding its ability (or otherwise...) to create Arduino code, I'd be a little wary of it! I doubt this will happen, but as you say, it would be good if somebody who's actually written a successful plugin could perhaps comment on this?

 

The other thing I'd like to know is - exactly what instructions did you give ChatGPT?

SteveG_AudioMasters_
Community Expert
Community Expert
May 19, 2024

I did a little checking. According to some people, Extendscript is officially dead - which may explain why there's so little extant information about it. What may be a larger problem is that it's apparently 32-bit, whereas Audition isn't. There's a thread in Adobe's Coding Corner you might like to read - here - and possibly some more as well; I haven't investigated this very much.