-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create index.d.ts #4
Open
goatandsheep
wants to merge
1
commit into
killercrush:master
Choose a base branch
from
goatandsheep:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable @typescript-eslint/member-ordering */
/* eslint-disable max-len */
declare module 'music-tempo' {
/* Partially generated using `
npx -p typescript tsc node_modules/music-tempo/src/MusicTempo.js --declaration --allowJs --emitDeclarationOnly --outDir types
npx -p typescript tsc node_modules/music-tempo/src/Agent.js --declaration --allowJs --emitDeclarationOnly --outDir types
` */
/**
* Class combines the work of all the steps of tempo extraction
* @class
*/
export default class MusicTempo {
/**
* Spectral flux
* @type {Array}
*/
spectralFlux: unknown[]
/**
* Spectral flux peaks indexes
* @type {Array}
*/
peaks: unknown[]
/**
* Onsets times array
* @type {Array}
*/
events: unknown[]
/**
* Tempo hypotheses array
* @type {Array}
*/
tempoList: unknown[]
/**
* Agents array
* @type {Array}
*/
agents: unknown[]
/**
* The tempo value in beats per minute
* @type {String}
*/
tempo: string
/**
* Beat times array
* @type {Array}
*/
beats: unknown[]
/**
* Inter-beat interval
* @type {Number}
*/
beatInterval: number
/**
* The agent with the highest score
* @type {Agent}
*/
bestAgent: Agent
/**
* Constructor
* @param {Float32Array} audioData - non-interleaved IEEE 32-bit linear PCM with a nominal range of -1 -> +1 (Web Audio API - Audio Buffer)
* @param {Object} [params={}] - parameters
* @param {Number} [params.bufferSize=2048] - FFT windows size
* @param {Number} [params.hopSize=441] - spacing of audio frames in samples
* @param {Number} [params.decayRate=0.84] - how quickly previous peaks are forgotten
* @param {Number} [params.peakFindingWindow=6] - minimum distance between peaks
* @param {Number} [params.meanWndMultiplier=3] - multiplier for peak finding window
* @param {Number} [params.peakThreshold=0.35] - minimum value of peaks
* @param {Number} [params.widthTreshold=0.025] - the maximum difference in IOIs which are in the same cluster
* @param {Number} [params.maxIOI=2.5] - the maximum IOI for inclusion in a cluster
* @param {Number} [params.minIOI=0.07] - the minimum IOI for inclusion in a cluster
* @param {Number} [params.maxTempos=10] - initial amount of tempo hypotheses
* @param {Number} [params.minBeatInterval=0.3] - the minimum inter-beat interval (IBI) (0.30 seconds == 200 BPM)
* @param {Number} [params.maxBeatInterval=1] - the maximum inter-beat interval (IBI) (1.00 seconds == 60 BPM)
* @param {Number} [params.initPeriod=5] - duration of the initial section
* @param {Number} [params.thresholdBI=0.02] - for the purpose of removing duplicate agents, the default JND of IBI
* @param {Number} [params.thresholdBT=0.04] - for the purpose of removing duplicate agents, the default JND of phase
* @param {Number} [params.expiryTime=10] - the time after which an Agent that has not accepted any beat will be destroyed
* @param {Number} [params.toleranceWndInner=0.04] - the maximum time that a beat can deviate from the predicted beat time without a fork occurring
* @param {Number} [params.toleranceWndPre=0.15] - the maximum amount by which a beat can be earlier than the predicted beat time, expressed as a fraction of the beat period
* @param {Number} [params.toleranceWndPost=0.3] - the maximum amount by which a beat can be later than the predicted beat time, expressed as a fraction of the beat period
* @param {Number} [params.correctionFactor=50] - correction factor for updating beat period
* @param {Number} [params.maxChange=0.2] - the maximum allowed deviation from the initial tempo, expressed as a fraction of the initial beat period
* @param {Number} [params.penaltyFactor=0.5] - factor for correcting score, if onset do not coincide precisely with predicted beat time
*/
constructor(audioData: Float32Array, params?: {
bufferSize?: number
hopSize?: number
decayRate?: number
peakFindingWindow?: number
meanWndMultiplier?: number
peakThreshold?: number
widthTreshold?: number
maxIOI?: number
minIOI?: number
maxTempos?: number
minBeatInterval?: number
maxBeatInterval?: number
initPeriod?: number
thresholdBI?: number
thresholdBT?: number
expiryTime?: number
toleranceWndInner?: number
toleranceWndPre?: number
toleranceWndPost?: number
correctionFactor?: number
maxChange?: number
penaltyFactor?: number
})
}
class Agent {
/**
* Constructor
* @param {Number} tempo - tempo hypothesis of the Agent
* @param {Number} firstBeatTime - the time of the first beat accepted by this Agent
* @param {Number} firsteventScore - salience value of the first beat accepted by this Agent
* @param {Array} agentList - reference to the agent list
* @param {Object} [params={}] - parameters
* @param {Number} [params.expiryTime=10] - the time after which an Agent that has not accepted any beat will be destroyed
* @param {Number} [params.toleranceWndInner=0.04] - the maximum time that a beat can deviate from the predicted beat time without a fork occurring
* @param {Number} [params.toleranceWndPre=0.15] - the maximum amount by which a beat can be earlier than the predicted beat time, expressed as a fraction of the beat period
* @param {Number} [params.toleranceWndPost=0.3] - the maximum amount by which a beat can be later than the predicted beat time, expressed as a fraction of the beat period
* @param {Number} [params.correctionFactor=50] - correction factor for updating beat period
* @param {Number} [params.maxChange=0.2] - the maximum allowed deviation from the initial tempo, expressed as a fraction of the initial beat period
* @param {Number} [params.penaltyFactor=0.5] - factor for correcting score, if onset do not coincide precisely with predicted beat time
*/
constructor(tempo: number, firstBeatTime: number, firsteventScore: number, agentList: unknown[], params?: {
expiryTime?: number
toleranceWndInner?: number
toleranceWndPre?: number
toleranceWndPost?: number
correctionFactor?: number
maxChange?: number
penaltyFactor?: number
})
/**
* the time after which an Agent that has not accepted any beat will be destroyed
* @type {Number}
*/
expiryTime: number
/**
* the maximum time that a beat can deviate from the predicted beat time without a fork occurring
* @type {Number}
*/
toleranceWndInner: number
/**
* the maximum amount by which a beat can be earlier than the predicted beat time, expressed as a fraction of the beat period
* @type {Number}
*/
toleranceWndPre: number
/**
* the maximum amount by which a beat can be later than the predicted beat time, expressed as a fraction of the beat period
* @type {Number}
*/
toleranceWndPost: number
/**
* correction factor for updating beat period
* @type {Number}
*/
correctionFactor: number
/**
* the maximum allowed deviation from the initial tempo, expressed as a fraction of the initial beat period
* @type {Number}
*/
maxChange: number
/**
* factor for correcting score, if onset do not coincide precisely with predicted beat time
* @type {Number}
*/
penaltyFactor: number
/**
* the current tempo hypothesis of the Agent, expressed as the beat period
* @type {Number}
*/
beatInterval: number
/**
* the initial tempo hypothesis of the Agent, expressed as the beat period
* @type {Number}
*/
initialBeatInterval: number
/**
* the time of the most recent beat accepted by this Agent
* @type {Number}
*/
beatTime: number
/**
* the number of beats found by this Agent, including interpolated beats
* @type {Number}
*/
totalBeatCount: number
/**
* the array of onsets accepted by this Agent as beats, plus interpolated beats
* @type {Array}
*/
events: unknown[]
/**
* sum of salience values of the onsets which have been interpreted as beats by this Agent
* @type {Number}
*/
score: number
/**
* reference to the agent list
* @type {Array}
*/
agentListRef: Agent[]
/**
* The event time is tested if it is a beat time
* @param {Number} eventTime - the event time to be tested
* @param {Number} eventScore - salience values of the event time
* @return {Boolean} indicate whether the given event time was accepted as a beat time
*/
considerEvent(eventTime: number, eventScore: number): boolean
/**
* Accept the event time as a beat time, and update the state of the Agent accordingly
* @param {Number} eventTime - the event time to be accepted
* @param {Number} eventScore - salience values of the event time
* @param {Number} err - the difference between the predicted and actual beat times
* @param {Number} beatCount - the number of beats since the last beat
*/
acceptEvent(eventTime: number, eventScore: number, err: number, beatCount: number): void
/**
* Interpolates missing beats in the Agent's beat track
*/
fillBeats(): void
/**
* Makes a clone of the Agent
* @return {Agent} agent's clone
*/
clone(): Agent
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.