Skip to content
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

Collect audio property values #28

Closed
abrahamjuliot opened this issue Jul 18, 2020 · 1 comment
Closed

Collect audio property values #28

abrahamjuliot opened this issue Jul 18, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@abrahamjuliot
Copy link
Owner

No description provided.

@abrahamjuliot abrahamjuliot added the enhancement New feature or request label Jul 18, 2020
@abrahamjuliot
Copy link
Owner Author

abrahamjuliot commented Jul 19, 2020

Concept inspired by https://audiofingerprint.openwpm.com:
https://es6console.com/kd9pjq7z/

const hashMini = str => {
  const json = `${JSON.stringify(str)}`
  let i, len, hash = 0x811c9dc5
  for (i = 0, len = json.length; i < len; i++) {
    hash = Math.imul(31, hash) + json.charCodeAt(i) | 0
  }
  return ('0000000' + (hash >>> 0).toString(16)).substr(-8)
}

const getAudioProps = () => {
  const contextOffline = OfflineAudioContext || webkitOfflineAudioContext
  const audioOffline = new contextOffline(1, 44100, 44100)
  const oscillator = audioOffline.createOscillator()
  const dynamicsCompressor = audioOffline.createDynamicsCompressor()
  const analyser = audioOffline.createAnalyser()
  const biquadFilter = audioOffline.createBiquadFilter()

  const audioData = {
    analyserChannelCount: analyser.channelCount,
    analyserChannelCountMode: analyser.channelCountMode,
    analyserChannelInterpretation: analyser.channelInterpretation,
    analyserSampleRate: analyser.context.sampleRate,
    analyserFftSize: analyser.fftSize,
    analyserFrequencyBinCount: analyser.frequencyBinCount,
    analyserMaxDecibels: analyser.maxDecibels,
    analyserMinDecibels: analyser.minDecibels,
    analyserNumberOfInputs: analyser.numberOfInputs,
    analyserNumberOfOutputs: analyser.numberOfOutputs,
    analyserSmoothingTimeConstant: analyser.smoothingTimeConstant,
    analyserContextListenerForwardXMax: analyser.context.listener.forwardX.maxValue,
    dynamicsCompressorAttackDefault: dynamicsCompressor.attack.defaultValue,
    dynamicsCompressorKneeDefault: dynamicsCompressor.knee.defaultValue,
    dynamicsCompressorKneeMax: dynamicsCompressor.knee.maxValue,
    dynamicsCompressorRatioDefault: dynamicsCompressor.ratio.defaultValue,
    dynamicsCompressorRatioMax: dynamicsCompressor.ratio.maxValue,
    dynamicsCompressorReleaseDefault: dynamicsCompressor.release.defaultValue,
    dynamicsCompressorReleaseMax: dynamicsCompressor.release.maxValue,
    dynamicsCompressorThresholdDefault: dynamicsCompressor.threshold.defaultValue,
    dynamicsCompressorThresholdMin: dynamicsCompressor.threshold.minValue,
    oscillatorDetuneMax: oscillator.detune.maxValue,
    oscillatorDetuneMin: oscillator.detune.minValue,
    oscillatorFrequencyDefault: oscillator.frequency.defaultValue,
    oscillatorFrequencyMax: oscillator.frequency.maxValue,
    oscillatorFrequencyMin: oscillator.frequency.minValue,
    biquadFilterGainMax: biquadFilter.gain.maxValue,
    biquadFilterFrequencyMax: biquadFilter.frequency.maxValue,
    biquadFilterFrequencyMin: biquadFilter.frequency.minValue
  }
  //console.log(biquadFilter)
  
  return audioData

}

a = getAudioProps()
console.log(a)

@abrahamjuliot abrahamjuliot self-assigned this Jul 19, 2020
@abrahamjuliot abrahamjuliot pinned this issue Jul 19, 2020
abrahamjuliot added a commit that referenced this issue Jul 19, 2020
@abrahamjuliot abrahamjuliot unpinned this issue Jul 19, 2020
abrahamjuliot added a commit that referenced this issue Jul 31, 2020
abrahamjuliot added a commit that referenced this issue Aug 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant