Vital
Loading...
Searching...
No Matches
AudioFileDropSource Class Referenceabstract

A helper class for handling drag-and-drop of audio files into a JUCE component. More...

#include <audio_file_drop_source.h>

Inheritance diagram for AudioFileDropSource:
AudioFileViewer SampleViewer WaveSourceEditor Wavetable3d

Classes

class  Listener
 A listener interface for classes interested in receiving audio file load events. More...
 

Public Member Functions

 AudioFileDropSource ()
 Constructs an AudioFileDropSource and registers basic audio formats.
 
bool isInterestedInFileDrag (const StringArray &files) override
 Checks if the drag operation includes exactly one file and if it matches supported audio formats.
 
void filesDropped (const StringArray &files, int x, int y) override
 Called when files are dropped onto the component.
 
virtual void audioFileLoaded (const File &file)=0
 Called internally when a recognized audio file is dropped. Must be implemented by subclasses.
 
void addListener (Listener *listener)
 Adds a listener to receive audio file load notifications.
 
String getExtensions ()
 Gets a wildcard pattern representing all supported audio formats.
 
AudioFormatManager & formatManager ()
 Provides access to the underlying AudioFormatManager.
 

Protected Attributes

AudioFormatManager format_manager_
 Manages and recognizes different audio file formats.
 

Detailed Description

A helper class for handling drag-and-drop of audio files into a JUCE component.

AudioFileDropSource integrates with JUCE's FileDragAndDropTarget to respond when a user drags and drops an audio file over a component. It:

  • Registers basic audio formats with an AudioFormatManager.
  • Checks if a dropped file is a supported audio format.
  • Notifies registered listeners when an audio file has been dropped and loaded.

Subclasses must implement audioFileLoaded(const File& file) to define custom loading behavior, and can add listeners that also receive audio file load notifications.

Constructor & Destructor Documentation

◆ AudioFileDropSource()

AudioFileDropSource::AudioFileDropSource ( )
inline

Constructs an AudioFileDropSource and registers basic audio formats.

Member Function Documentation

◆ addListener()

void AudioFileDropSource::addListener ( Listener * listener)
inline

Adds a listener to receive audio file load notifications.

Parameters
listenerThe listener to add.

◆ audioFileLoaded()

virtual void AudioFileDropSource::audioFileLoaded ( const File & file)
pure virtual

Called internally when a recognized audio file is dropped. Must be implemented by subclasses.

Parameters
fileThe dropped audio file.

Implemented in AudioFileViewer, SampleViewer, WaveSourceEditor, and Wavetable3d.

◆ filesDropped()

void AudioFileDropSource::filesDropped ( const StringArray & files,
int x,
int y )
inlineoverride

Called when files are dropped onto the component.

If at least one file is dropped, it calls audioFileLoaded with the first file and notifies all listeners.

Parameters
filesThe array of dropped files.
xThe x-coordinate of the drop (unused).
yThe y-coordinate of the drop (unused).

◆ formatManager()

AudioFormatManager & AudioFileDropSource::formatManager ( )
inline

Provides access to the underlying AudioFormatManager.

Returns
A reference to the AudioFormatManager.

◆ getExtensions()

String AudioFileDropSource::getExtensions ( )
inline

Gets a wildcard pattern representing all supported audio formats.

Returns
A string containing wildcard patterns for all recognized audio formats (e.g. "*.wav;*.aif").

◆ isInterestedInFileDrag()

bool AudioFileDropSource::isInterestedInFileDrag ( const StringArray & files)
inlineoverride

Checks if the drag operation includes exactly one file and if it matches supported audio formats.

Parameters
filesThe list of files being dragged.
Returns
True if there's a single file and it matches a known audio format, false otherwise.

Member Data Documentation

◆ format_manager_

AudioFormatManager AudioFileDropSource::format_manager_
protected

Manages and recognizes different audio file formats.


The documentation for this class was generated from the following file: