// applyEffect(trackId: string, effectName: string, effectArgs: number[]);
// Adds a button which inserts an effect on the given track, with the given arguments.
// Effects and arguments:
// eq: freq, gain, q
// hpf: freq, q
// lpf: freq, q
// compressor: thresh, ratio
// gate: thresh (usually under -40dB)
// limiter: gain (usually at least 6dB)
// reverb: mix
// delay: beats, feedback, mix
// distortion: gain
// bitcrush: bitDepth, sampleRate (bitDepth 1 to 16, sampleRate 20 to 40000)
// no other effects exist! if a user asks for another effect, apologize and tell them you're still in development.
// 'mix' is a number between 0 and 1.
// thresh/gain are in dB.

const referenceFAQ = {
  name: 'referenceFAQ',
  description:
    'If the user asks how to perform a specific action which, to answer, you may need to know more about the WavTool UI or application, use this function.',
  parameters: {
    type: 'object',
    properties: { question: { type: 'string', description: 'The question you would like answered.' } },
  },
};

const setBPM = {
  name: 'setBPM',
  description: 'Sets the BPM of the project',
  parameters: {
    type: 'object',
    properties: { bpm: { type: 'number', description: 'The BPM to change the project to.' } },
  },
};

const applySidechainCompression = {
  name: 'applySidechainCompression',
  description: 'Applies sidechain compression to a track from a source track.',
  parameters: {
    type: 'object',
    properties: {
      trackId: { type: 'string', description: 'The track ID of the source track' },
      sidechainTrackId: { type: 'string', description: 'The track ID of the sidechained track.' },
    },
  },
};

const addTrack = {
  name: 'addTrack',
  description: 'Adds a track to the project.',
  parameters: {
    type: 'object',
    properties: {
      trackId: { type: 'string', description: 'The ID of the newly added track' },
      trackName: { type: 'string', description: 'The name of the newly added track' },
      instrument: {
        type: 'string',
        enum: ['drums', 'synth', 'bass', 'piano'],
        description: 'The instrument type of the new track.',
      },
    },
  },
};

const getComposedMIDI = {
  name: 'getComposedMIDI',
  description: 'Retrieves a composition',
  parameters: {
    type: 'object',
    properties: {
      trackId: { type: 'string', description: 'The ID of the track to add the clip to.' },
      instrument: {
        type: 'string',
        enum: ['Melody', 'Drums', 'Bass', 'Chords'],
        description: 'The instrument that the generated midi is for. Can be set to undefined if not specified.',
      },
    },
  },
};

const addTrackAndMIDIClip = {
  name: 'addTrackAndMIDIClip',
  description: 'Creates a new track and adds a newly composed MIDI clip containing the given notes.',
  parameters: {
    type: 'object',
    properties: {
      trackId: {
        type: 'string',
        description:
          'The ID of the track to be created. This MUST be a new track ID that does not exist in the project yet.',
      },
      trackName: { type: 'string', description: 'The name of the track to be created.' },
      loopPoint: {
        type: 'number',
        description:
          'The number of beats in the loop. Any notes added at or after this point will be ignored! This should usually be 16.',
      },
      instrument: {
        type: 'string',
        enum: ['Melody', 'Drums', 'Bass', 'Chords'],
        description: 'The instrument that the generated midi is for. Can be set to undefined if not specified.',
      },
    },
  },
};

// we aren't ready to replace any existing functions other than the FAQ embedding lookup yet
export const functions = [
  // setBPM, applySidechainCompression, addTrack, getComposedMIDI,
  referenceFAQ,
];
