Class default

Hierarchy

  • default

Constructors

Properties

authHeader: string = ''
clientId: string = ''
clientSecret: string = ''
host: string = 'freesound.org'
uris: { authorize: string; base: string; bookmark: string; combinedSearch: string; comment: string; comments: string; contentSearch: string; describe: string; download: string; logout: string; logoutAuthorize: string; me: string; pack: string; packDownload: string; packSounds: string; pending: string; rate: string; similarSounds: string; sound: string; soundAnalysis: string; textSearch: string; upload: string; user: string; userBookmarkCategories: string; userBookmarkCategorySounds: string; userPacks: string; userSounds: string } = ...

Type declaration

  • authorize: string
  • base: string
  • bookmark: string
  • combinedSearch: string
  • comment: string
  • comments: string
  • contentSearch: string
  • describe: string
  • download: string
  • logout: string
  • logoutAuthorize: string
  • me: string
  • pack: string
  • packDownload: string
  • packSounds: string
  • pending: string
  • rate: string
  • similarSounds: string
  • sound: string
  • soundAnalysis: string
  • textSearch: string
  • upload: string
  • user: string
  • userBookmarkCategories: string
  • userBookmarkCategorySounds: string
  • userPacks: string
  • userSounds: string

Methods

  • Type Parameters

    Type Parameters

    • T

    Parameters

    • oldJsonObject: RawCollection<T>

    Returns Collection<T>

  • Parameters

    • jsonObject: RawCollection<Pack>

    Returns { count: number; getItem: ((page: number) => Pack); getPack: ((idx: number) => Pack); next: string; nextOrPrev: ((page: string) => Promise<Collection<Pack>>); nextPage: ((page: number) => Promise<Collection<Pack>>); previous: string; previousPage: ((page: number) => Promise<Collection<Pack>>); results: Pack[] }

  • Parameters

    • oldJsonObject: RawPack

    Returns Pack

  • Parameters

    • oldJsonObject: RawSound

    Returns Sound

  • Parameters

    • oldJsonObject: RawUser

    Returns User

  • Search sounds in Freesound based on their tags, metadata and content-based descriptiors via a combination of text search and content search. See https://freesound.org/docs/api/resources_apiv2.html#combined-search for more information.

    const soundCollectionResults = await freeSound.combinedSearch(
    filter: 'tag:scale',
    target: 'rhythm.bpm:120',
    );

    Parameters

    • options: SearchOpts

    Returns Promise<unknown>

  • Describe a previously uploaded file that does not have a description. Note: after a sound receives a description, the team of Freesound moderators still needs to process and moderate it, so it may not yet appear in Freesound. A list of sounds uploaded and described by the user, but still pending processing and moderation, is viewable with the getPendingSounds() method. This method requires OAuth2 authentication. See https://freesound.org/docs/api/resources_apiv2.html#describe-sound-oauth2-required for more information.

    Parameters

    • description: { description: string }

      a description for an uploaded sound

      • description: string

    Returns Promise<unknown>

  • Type Parameters

    Type Parameters

    • T

    Parameters

    • uri: string
    • method: "GET" | "POST" = 'GET'
    • params: FormData | Record<string, undefined | string> = {}

    Returns Promise<Response>

  • Navigate to Freesound for user login.

    Returns

    a url where the user can login

    const navigateToLogin = () => {
    window.location.replace(freeSound.getLoginURL());
    };

    Returns string

  • Returns string

  • Retrieve the list of sounds included in a pack. See https://freesound.org/docs/api/resources_apiv2.html#pack-sounds for more information.

    Returns

    a list of sounds included in the pack that has packId as its identification number

    // Fetch the pack
    // https://freesound.org/people/vroomvro0om/packs/21143/.
    const packObj = await freeSound.getPack(21143);

    Parameters

    • packId: string | number

      the identification number of the pack to fetch

    • options: {} = {}

      Returns Promise<Pack>

    • Retrieve a list of audio files uploaded by he Freesound user logged in using OAuth2 are not described, processed or moderated. In Freesound, sounds need descriptions after their upload. Then, sounds are automatically processed, and, finally, a team of human moderators either accepts or rejects the upload. This method keeps track of the status of these uploads and requires OAuth2 authentication. See https://freesound.org/docs/api/resources_apiv2.html#pending-uploads-oauth2-required for more information.

      const result = await freeSound.getPendingSounds()
      

      Returns Promise<unknown>

    • Retrieve detailed information about a sound. See https://freesound.org/docs/api/resources_apiv2.html#sound-resources for more information.

      Returns

      detailed information about a sound

      // Fetch the sound
      // https://freesound.org/people/vroomvro0om/sounds/376626/.
      const fetchedSound = await freeSound.getSound(376626);

      Parameters

      • soundId: string | number

        the identification number of the sound

      Returns Promise<Sound>

    • Retrieve information about a particular Freesound user. See https://freesound.org/docs/api/resources_apiv2.html#user-instance for more information.

      Returns

      information about a particular Freesound user

      // Get information about the user https://freesound.org/people/MTG/.
      const user = await freeSound.getUser('MTG');

      Parameters

      • username: string

        the username of the Freesound user

      Returns Promise<User>

    • Parameters

      • obj: Record<string, undefined | string>
      • Optional prevFormData: FormData

      Returns FormData

    • Type Parameters

      Type Parameters

      • T

      Parameters

      • uri: string
      • method: "GET" | "POST" = 'GET'
      • params: FormData | Record<string, undefined | string> = {}

      Returns Promise<T>

    • Parameters

      • uri: string
      • Optional args: (string | number)[]

      Returns string

    • Return basic information about the user that is logged in via OAuth2. This application can use it to identify which Freesound user has logged in.

      const result = await freeSound.me();
      

      Returns Promise<unknown>

    • This method allows you to get a new token using a refresh token or an auth token

      await freeSound.postAccessCode('your-temporary-code-from-login');
      

      Parameters

      • token: string
      • type: "refresh" | "auth" = 'auth'

      Returns Promise<AccessTokenResponse>

    • Type Parameters

      Type Parameters

      • T

      Parameters

      • options: SearchOpts
      • uri: string

      Returns Promise<T>

    • There are two ways of authenticating: OAuth and token method. The OAuth method is required for more privilidged actions such as downloading sounds.

      This method can set both kinds of tokens

      await freeSound.setToken('your-api-key', 'oauth');
      

      Parameters

      • token: string
      • Optional type: "oauth"

      Returns string

    • Upload an audio file into Freesound and optionally describe it. If there is no file description, only the audio file will upload, and the user will need to add a description later using the describe(description: { description: string }) method. If the file description is present, the uploaded file will be ready for the processing and moderation stage. A list of uploaded files pending a description, processing or moderation is obtainable through the getPendingSounds() method. See https://freesound.org/docs/api/resources_apiv2.html#upload-sound-oauth2-required for more information. This method requires OAuth2 authentication.

      Parameters

      • audiofile: string

        the audio file to upload

      • filename: string

        the name of the audio file to upload

      • description: { description: string }

        the description of the audio file to upload

        • description: string

      Returns Promise<unknown>

    Generated using TypeDoc