Repository: motion-canvas/motion-canvas
File: packages/core/src/app/Renderer.ts (TypeScript)

Code before:
    }

    await this.exporter.stop?.(result);
    this.exporter = null;
    return result;
  }

  private async reloadScenes(settings: RendererSettings) {
    for (let i = 0; i < this.project.scenes.length; i++) {
      const description = this.project.scenes[i];
      const scene = this.playback.onScenesRecalculated.current[i];
      scene.reload({
        config: description.onReplaced.current.config,
        size: settings.size,
        resolutionScale: settings.resolutionScale,
      });
      scene.meta.set(description.meta.get());
      scene.variables.updateSignals(this.project.variables ?? {});
    }
  }

  private async provideSounds() {
    const sounds: Sound[] = [];
    for (let i = 0; i < this.project.scenes.length; i++) {
      const scene = this.playback.onScenesRecalculated.current[i];
      sounds.push(...(<Sound[]>(<any>scene.sounds).sounds));
    }
    await this.exporter!.provideSounds?.(sounds);
  }

  private async exportFrame(signal: AbortSignal) {
    this.frame.current = this.playback.frame;
    await this.stage.render(
      this.playback.currentScene!,
      this.playback.previousScene,
    );

    const sceneFrame =
      this.playback.frame - this.playback.currentScene.firstFrame;
    await this.exporter!.handleFrame(
      this.stage.finalBuffer,
      this.playback.frame,
      sceneFrame,
      this.playback.currentScene.name,
      signal,
    );
  }
}


Review comment (suggestion):
You can just do:
```suggestion
    for (const scene of this.playback.onScenesRecalculated.current) {
      sounds.push(...scene.sounds.getSounds());
    }
```
I'm using fori in the method above because I need to access both the scene and its description over there. Here we only need scenes.

Code after:
      result = RendererResult.Error;
    }

    await this.exporter.stop?.(result);
    this.exporter = null;
    return result;
  }

  private async reloadScenes(settings: RendererSettings) {
    for (let i = 0; i < this.project.scenes.length; i++) {
      const description = this.project.scenes[i];
      const scene = this.playback.onScenesRecalculated.current[i];
      scene.reload({
        config: description.onReplaced.current.config,
        size: settings.size,
        resolutionScale: settings.resolutionScale,
      });
      scene.meta.set(description.meta.get());
      scene.variables.updateSignals(this.project.variables ?? {});
    }
  }

  private collectSounds() {
    const sounds: Sound[] = [];
    for (const scene of this.playback.onScenesRecalculated.current) {
      sounds.push(...scene.sounds.getSounds());
    }
    return sounds;
  }

  private async exportFrame(signal: AbortSignal) {
    this.frame.current = this.playback.frame;
    await this.stage.render(
      this.playback.currentScene!,
      this.playback.previousScene,
    );

    const sceneFrame =
      this.playback.frame - this.playback.currentScene.firstFrame;
    await this.exporter!.handleFrame(
      this.stage.finalBuffer,
      this.playback.frame,
      sceneFrame,
      this.playback.currentScene.name,
      signal,
      this.stage.context,
    );
  }
}