@siteed/expo-audio-stream 1.0.5 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +21 -5
  2. package/android/src/main/java/net/siteed/audiostream/AudioProcessor.kt +47 -7
  3. package/android/src/main/java/net/siteed/audiostream/Constants.kt +5 -0
  4. package/android/src/main/java/net/siteed/audiostream/ExpoAudioStreamModule.kt +12 -3
  5. package/build/index.js +3 -2
  6. package/ios/AudioProcessor.swift +7 -5
  7. package/ios/ExpoAudioStream.podspec +1 -1
  8. package/ios/ExpoAudioStreamModule.swift +35 -0
  9. package/package.json +26 -3
  10. package/src/ExpoAudioStream.types.ts +3 -0
  11. package/src/ExpoAudioStream.web.ts +0 -1
  12. package/src/ExpoAudioStreamModule.ts +8 -2
  13. package/src/index.ts +3 -1
  14. package/src/logger.ts +0 -1
  15. package/src/utils/writeWavHeader.ts +5 -0
  16. package/src/workers/InlineFeaturesExtractor.web.tsx +295 -285
  17. package/src/workers/inlineAudioWebWorker.web.tsx +229 -221
  18. package/.eslintrc.js +0 -2
  19. package/.size-limit.json +0 -6
  20. package/android/.gradle/8.1.1/checksums/checksums.lock +0 -0
  21. package/android/.gradle/8.1.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  22. package/android/.gradle/8.1.1/dependencies-accessors/gc.properties +0 -0
  23. package/android/.gradle/8.1.1/fileChanges/last-build.bin +0 -0
  24. package/android/.gradle/8.1.1/fileHashes/fileHashes.lock +0 -0
  25. package/android/.gradle/8.1.1/gc.properties +0 -0
  26. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  27. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  28. package/android/.gradle/vcs-1/gc.properties +0 -0
  29. package/app.plugin.js +0 -1
  30. package/build/AudioAnalysis/AudioAnalysis.types.d.ts +0 -74
  31. package/build/AudioAnalysis/AudioAnalysis.types.d.ts.map +0 -1
  32. package/build/AudioAnalysis/AudioAnalysis.types.js +0 -3
  33. package/build/AudioAnalysis/AudioAnalysis.types.js.map +0 -1
  34. package/build/AudioAnalysis/extractAudioAnalysis.d.ts +0 -20
  35. package/build/AudioAnalysis/extractAudioAnalysis.d.ts.map +0 -1
  36. package/build/AudioAnalysis/extractAudioAnalysis.js +0 -88
  37. package/build/AudioAnalysis/extractAudioAnalysis.js.map +0 -1
  38. package/build/AudioAnalysis/extractWaveform.d.ts +0 -8
  39. package/build/AudioAnalysis/extractWaveform.d.ts.map +0 -1
  40. package/build/AudioAnalysis/extractWaveform.js +0 -14
  41. package/build/AudioAnalysis/extractWaveform.js.map +0 -1
  42. package/build/AudioRecorder.provider.d.ts +0 -23
  43. package/build/AudioRecorder.provider.d.ts.map +0 -1
  44. package/build/AudioRecorder.provider.js +0 -36
  45. package/build/AudioRecorder.provider.js.map +0 -1
  46. package/build/ExpoAudioStream.native.d.ts +0 -3
  47. package/build/ExpoAudioStream.native.d.ts.map +0 -1
  48. package/build/ExpoAudioStream.native.js +0 -6
  49. package/build/ExpoAudioStream.native.js.map +0 -1
  50. package/build/ExpoAudioStream.types.d.ts +0 -62
  51. package/build/ExpoAudioStream.types.d.ts.map +0 -1
  52. package/build/ExpoAudioStream.types.js +0 -2
  53. package/build/ExpoAudioStream.types.js.map +0 -1
  54. package/build/ExpoAudioStream.web.d.ts +0 -42
  55. package/build/ExpoAudioStream.web.d.ts.map +0 -1
  56. package/build/ExpoAudioStream.web.js +0 -203
  57. package/build/ExpoAudioStream.web.js.map +0 -1
  58. package/build/ExpoAudioStreamModule.d.ts +0 -3
  59. package/build/ExpoAudioStreamModule.d.ts.map +0 -1
  60. package/build/ExpoAudioStreamModule.js +0 -19
  61. package/build/ExpoAudioStreamModule.js.map +0 -1
  62. package/build/WebRecorder.web.d.ts +0 -51
  63. package/build/WebRecorder.web.d.ts.map +0 -1
  64. package/build/WebRecorder.web.js +0 -298
  65. package/build/WebRecorder.web.js.map +0 -1
  66. package/build/constants.d.ts +0 -11
  67. package/build/constants.d.ts.map +0 -1
  68. package/build/constants.js +0 -14
  69. package/build/constants.js.map +0 -1
  70. package/build/events.d.ts +0 -18
  71. package/build/events.d.ts.map +0 -1
  72. package/build/events.js +0 -15
  73. package/build/events.js.map +0 -1
  74. package/build/index.d.ts +0 -10
  75. package/build/index.d.ts.map +0 -1
  76. package/build/index.js.map +0 -1
  77. package/build/logger.d.ts +0 -9
  78. package/build/logger.d.ts.map +0 -1
  79. package/build/logger.js +0 -13
  80. package/build/logger.js.map +0 -1
  81. package/build/useAudioRecorder.d.ts +0 -20
  82. package/build/useAudioRecorder.d.ts.map +0 -1
  83. package/build/useAudioRecorder.js +0 -271
  84. package/build/useAudioRecorder.js.map +0 -1
  85. package/build/utils/BlobFix.d.ts +0 -9
  86. package/build/utils/BlobFix.d.ts.map +0 -1
  87. package/build/utils/BlobFix.js +0 -494
  88. package/build/utils/BlobFix.js.map +0 -1
  89. package/build/utils/concatenateBuffers.d.ts +0 -8
  90. package/build/utils/concatenateBuffers.d.ts.map +0 -1
  91. package/build/utils/concatenateBuffers.js +0 -21
  92. package/build/utils/concatenateBuffers.js.map +0 -1
  93. package/build/utils/convertPCMToFloat32.d.ts +0 -11
  94. package/build/utils/convertPCMToFloat32.d.ts.map +0 -1
  95. package/build/utils/convertPCMToFloat32.js +0 -54
  96. package/build/utils/convertPCMToFloat32.js.map +0 -1
  97. package/build/utils/encodingToBitDepth.d.ts +0 -5
  98. package/build/utils/encodingToBitDepth.d.ts.map +0 -1
  99. package/build/utils/encodingToBitDepth.js +0 -13
  100. package/build/utils/encodingToBitDepth.js.map +0 -1
  101. package/build/utils/getWavFileInfo.d.ts +0 -26
  102. package/build/utils/getWavFileInfo.d.ts.map +0 -1
  103. package/build/utils/getWavFileInfo.js +0 -92
  104. package/build/utils/getWavFileInfo.js.map +0 -1
  105. package/build/utils/writeWavHeader.d.ts +0 -9
  106. package/build/utils/writeWavHeader.d.ts.map +0 -1
  107. package/build/utils/writeWavHeader.js +0 -41
  108. package/build/utils/writeWavHeader.js.map +0 -1
  109. package/build/workers/InlineFeaturesExtractor.web.d.ts +0 -2
  110. package/build/workers/InlineFeaturesExtractor.web.d.ts.map +0 -1
  111. package/build/workers/InlineFeaturesExtractor.web.js +0 -303
  112. package/build/workers/InlineFeaturesExtractor.web.js.map +0 -1
  113. package/build/workers/inlineAudioWebWorker.web.d.ts +0 -2
  114. package/build/workers/inlineAudioWebWorker.web.d.ts.map +0 -1
  115. package/build/workers/inlineAudioWebWorker.web.js +0 -243
  116. package/build/workers/inlineAudioWebWorker.web.js.map +0 -1
  117. package/expo-module.config.json +0 -9
  118. package/plugin/build/index.d.ts +0 -5
  119. package/plugin/build/index.js +0 -28
  120. package/plugin/src/index.ts +0 -53
  121. package/plugin/tsconfig.json +0 -9
  122. package/publish.sh +0 -8
  123. package/tsconfig.json +0 -14
@@ -1 +0,0 @@
1
- {"version":3,"file":"InlineFeaturesExtractor.web.js","sourceRoot":"","sources":["../../src/workers/InlineFeaturesExtractor.web.tsx"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6StC,CAAA","sourcesContent":["export const InlineFeaturesExtractor = `\n\n// Unique ID counter\nlet uniqueIdCounter = 0;\n\nself.onmessage = function (event) {\n const {\n channelData, // this is only the newly recorded data when live recording.\n sampleRate,\n pointsPerSecond,\n algorithm,\n bitDepth,\n fullAudioDurationMs,\n numberOfChannels,\n features: _features,\n } = event.data;\n\n console.log(\"[AudioFeaturesExtractor] Worker received message\", event.data);\n const features = _features || {};\n\n const SILENCE_THRESHOLD = 0.01;\n const MIN_SILENCE_DURATION = 1.5 * sampleRate; // 1.5 seconds of silence\n const SPEECH_INERTIA_DURATION = 0.1 * sampleRate; // Speech inertia duration in samples\n const RMS_THRESHOLD = 0.01;\n const ZCR_THRESHOLD = 0.1;\n\n // Placeholder functions for feature extraction\n const extractMFCC = (segmentData, sampleRate) => {\n // Implement MFCC extraction logic here\n return [];\n };\n\n const extractSpectralCentroid = (segmentData, sampleRate) => {\n const magnitudeSpectrum = segmentData.map((v) => v * v);\n const sum = magnitudeSpectrum.reduce((a, b) => a + b, 0);\n if (sum === 0) return 0;\n\n const weightedSum = magnitudeSpectrum.reduce(\n (acc, value, index) => acc + index * value,\n 0,\n );\n return ((weightedSum / sum) * (sampleRate / 2)) / magnitudeSpectrum.length;\n };\n\n const extractSpectralFlatness = (segmentData) => {\n const magnitudeSpectrum = segmentData.map((v) => Math.abs(v));\n const geometricMean = Math.exp(\n magnitudeSpectrum\n .map((v) => Math.log(v + Number.MIN_VALUE))\n .reduce((a, b) => a + b) / magnitudeSpectrum.length,\n );\n const arithmeticMean =\n magnitudeSpectrum.reduce((a, b) => a + b) / magnitudeSpectrum.length;\n return arithmeticMean === 0 ? 0 : geometricMean / arithmeticMean;\n };\n\n const extractSpectralRollOff = (segmentData, sampleRate) => {\n const magnitudeSpectrum = segmentData.map((v) => Math.abs(v));\n const totalEnergy = magnitudeSpectrum.reduce((a, b) => a + b, 0);\n const rollOffThreshold = totalEnergy * 0.85;\n let cumulativeEnergy = 0;\n\n for (let i = 0; i < magnitudeSpectrum.length; i++) {\n cumulativeEnergy += magnitudeSpectrum[i];\n if (cumulativeEnergy >= rollOffThreshold) {\n return (i / magnitudeSpectrum.length) * (sampleRate / 2);\n }\n }\n\n return 0;\n };\n\n const extractSpectralBandwidth = (segmentData, sampleRate) => {\n const centroid = extractSpectralCentroid(segmentData, sampleRate);\n const magnitudeSpectrum = segmentData.map((v) => Math.abs(v));\n const sum = magnitudeSpectrum.reduce((a, b) => a + b, 0);\n if (sum === 0) return 0;\n\n const weightedSum = magnitudeSpectrum.reduce(\n (acc, value, index) => acc + value * Math.pow(index - centroid, 2),\n 0,\n );\n return Math.sqrt(weightedSum / sum);\n };\n\n const extractChromagram = (segmentData, sampleRate) => {\n return []; // TODO implement\n };\n\n const extractHNR = (segmentData) => {\n const frameSize = segmentData.length;\n const autocorrelation = new Float32Array(frameSize);\n\n // Compute the autocorrelation of the segment data\n for (let i = 0; i < frameSize; i++) {\n let sum = 0;\n for (let j = 0; j < frameSize - i; j++) {\n sum += segmentData[j] * segmentData[j + i];\n }\n autocorrelation[i] = sum;\n }\n\n // Find the maximum autocorrelation value (excluding the zero lag)\n const maxAutocorrelation = Math.max(...autocorrelation.subarray(1));\n\n // Compute the HNR\n return autocorrelation[0] !== 0\n ? 10 *\n Math.log10(\n maxAutocorrelation / (autocorrelation[0] - maxAutocorrelation),\n )\n : 0;\n };\n\n const extractWaveform = (\n channelData, // Float32Array\n sampleRate, // number\n pointsPerSecond, // number\n algorithm, // string\n ) => {\n const totalSamples = channelData.length;\n const segmentDuration = totalSamples / sampleRate;\n const totalPoints = Math.max(\n Math.ceil(segmentDuration * pointsPerSecond),\n 1,\n );\n const pointInterval = Math.ceil(totalSamples / totalPoints);\n const dataPoints = [];\n let minAmplitude = Infinity;\n let maxAmplitude = -Infinity;\n let silenceStart = null;\n let lastSpeechEnd = -Infinity;\n let isSpeech = false;\n\n const expectedPoints = segmentDuration * pointsPerSecond;\n const samplesPerPoint = Math.ceil(channelData.length / expectedPoints);\n\n for (let i = 0; i < expectedPoints; i++) {\n const start = i * samplesPerPoint;\n const end = Math.min(start + samplesPerPoint, totalSamples);\n\n let sumSquares = 0;\n let zeroCrossings = 0;\n let prevValue = channelData[start];\n let localMinAmplitude = Infinity;\n let localMaxAmplitude = -Infinity;\n let hasNonZeroValue = false;\n\n // compute values for the segment\n for (let j = start; j < end; j++) {\n const value = channelData[j];\n sumSquares += value * value;\n if (j > start && value * prevValue < 0) {\n zeroCrossings++;\n }\n prevValue = value;\n\n const absValue = Math.abs(value);\n localMinAmplitude = Math.min(localMinAmplitude, absValue);\n localMaxAmplitude = Math.max(localMaxAmplitude, absValue);\n\n if (absValue !== 0) {\n hasNonZeroValue = true;\n }\n }\n\n // Post-processing checks\n if (!hasNonZeroValue) {\n // All values are zero\n localMinAmplitude = 0;\n localMaxAmplitude = 0;\n }\n\n const rms = Math.sqrt(sumSquares / (end - start));\n minAmplitude = Math.min(minAmplitude, rms);\n maxAmplitude = Math.max(maxAmplitude, rms);\n\n const energy = sumSquares;\n const zcr = zeroCrossings / (end - start);\n\n const silent = rms < SILENCE_THRESHOLD;\n const dB = 20 * Math.log10(rms);\n\n if (silent) {\n if (silenceStart === null) {\n silenceStart = start;\n } else if (start - silenceStart > MIN_SILENCE_DURATION) {\n // Silence detected for longer than the threshold, set amplitude to 0\n localMaxAmplitude = 0;\n localMinAmplitude = 0;\n isSpeech = false;\n }\n } else {\n silenceStart = null;\n if (!isSpeech && start - lastSpeechEnd < SPEECH_INERTIA_DURATION) {\n isSpeech = true;\n }\n lastSpeechEnd = end;\n }\n\n const activeSpeech =\n (rms > RMS_THRESHOLD && zcr > ZCR_THRESHOLD) ||\n (isSpeech && start - lastSpeechEnd < SPEECH_INERTIA_DURATION);\n\n if (activeSpeech) {\n isSpeech = true;\n lastSpeechEnd = end;\n } else {\n isSpeech = false;\n }\n\n const bytesPerSample = bitDepth / 8;\n const startPosition = start * bytesPerSample * numberOfChannels; // Calculate start position in bytes\n const endPosition = end * bytesPerSample * numberOfChannels; // Calculate end position in bytes\n\n // Compute features\n const segmentData = channelData.slice(start, end);\n const mfcc = features.mfcc ? extractMFCC(segmentData, sampleRate) : [];\n const spectralCentroid = features.spectralCentroid\n ? extractSpectralCentroid(segmentData, sampleRate)\n : 0;\n const spectralFlatness = features.spectralFlatness\n ? extractSpectralFlatness(segmentData)\n : 0;\n const spectralRollOff = features.spectralRollOff\n ? extractSpectralRollOff(segmentData, sampleRate)\n : 0;\n const spectralBandwidth = features.spectralBandwidth\n ? extractSpectralBandwidth(segmentData, sampleRate)\n : 0;\n const chromagram = features.chromagram\n ? extractChromagram(segmentData, sampleRate)\n : [];\n const hnr = features.hnr ? extractHNR(segmentData) : 0;\n\n const newData = {\n id: uniqueIdCounter++, // Assign unique ID and increment the counter\n amplitude: algorithm === \"peak\" ? localMaxAmplitude : rms,\n activeSpeech,\n dB,\n silent,\n features: {\n energy,\n rms,\n minAmplitude: localMinAmplitude,\n maxAmplitude: localMaxAmplitude,\n zcr,\n mfcc: [], // Placeholder for MFCC features\n spectralCentroid, // Computed spectral centroid\n spectralFlatness, // Computed spectral flatness\n spectralRollOff, // Computed spectral roll-off\n spectralBandwidth, // Computed spectral bandwidth\n chromagram, // Computed chromagram\n hnr, // Computed HNR\n },\n startTime: start / sampleRate,\n endTime: end / sampleRate,\n startPosition,\n endPosition,\n samples: end - start,\n speaker: 0, // Assuming speaker detection is to be handled later\n };\n\n dataPoints.push(newData);\n }\n\n return {\n pointsPerSecond,\n durationMs: fullAudioDurationMs,\n bitDepth,\n samples: totalSamples,\n numberOfChannels,\n sampleRate,\n dataPoints,\n amplitudeRange: {\n min: minAmplitude,\n max: maxAmplitude,\n },\n speakerChanges: [], // Placeholder for future speaker detection logic\n };\n };\n\n try {\n const result = extractWaveform(\n channelData,\n sampleRate,\n pointsPerSecond,\n algorithm,\n );\n self.postMessage({\n command: \"features\",\n result,\n });\n } catch (error) {\n console.error(\"[AudioFeaturesExtractor] Error in processing\", error);\n self.postMessage({ error: error.message });\n } finally {\n // Do not close the worker so it can be re-used for subsequent messages\n // self.close();\n }\n};\n`\n"]}
@@ -1,2 +0,0 @@
1
- export declare const InlineAudioWebWorker = "\nconst DEFAULT_BIT_DEPTH = 32;\nconst DEFAULT_SAMPLE_RATE = 44100;\n\nclass RecorderProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.recordedBuffers = []; // Float32Array\n this.newRecBuffer = []; // Float32Array\n this.resampledBuffer = []; // Float32Array\n this.exportIntervalSamples = 0;\n this.samplesSinceLastExport = 0;\n this.recordSampleRate = DEFAULT_SAMPLE_RATE; // To be overwritten\n this.exportSampleRate = DEFAULT_SAMPLE_RATE; // To be overwritten\n this.recordBitDepth = DEFAULT_BIT_DEPTH; // Default to 32-bit depth\n this.exportBitDepth = DEFAULT_BIT_DEPTH; // To be overwritten\n this.numberOfChannels = 1; // Default to 1 channel (mono)\n this.isRecording = true;\n this.port.onmessage = this.handleMessage.bind(this);\n }\n\n handleMessage(event) {\n switch (event.data.command) {\n case \"init\":\n this.recordSampleRate = event.data.recordSampleRate;\n this.exportSampleRate =\n event.data.exportSampleRate || event.data.recordSampleRate;\n this.exportIntervalSamples =\n this.recordSampleRate * (event.data.interval / 1000);\n if (event.data.numberOfChannels) {\n this.numberOfChannels = event.data.numberOfChannels;\n }\n if (event.data.recordBitDepth) {\n this.recordBitDepth = event.data.recordBitDepth;\n }\n this.exportBitDepth =\n event.data.exportBitDepth || this.recordBitDepth || DEFAULT_BIT_DEPTH;\n break;\n case \"stop\":\n this.isRecording = false;\n this.getAllRecordedData()\n .then((fullRecordedData) => {\n this.port.postMessage({\n command: \"recordedData\",\n recordedData: fullRecordedData,\n bitDepth: this.exportBitDepth,\n sampleRate: this.exportSampleRate,\n });\n return fullRecordedData;\n })\n .catch((error) => {\n console.error(\"Error extracting recorded data:\", error);\n });\n break;\n }\n }\n\n process(inputs, outputs, parameters) {\n if (!this.isRecording) return true;\n const input = inputs[0];\n if (input.length > 0) {\n const newBuffer = new Float32Array(input[0]);\n this.newRecBuffer.push(newBuffer);\n this.recordedBuffers.push(newBuffer);\n this.samplesSinceLastExport += newBuffer.length;\n\n if (this.samplesSinceLastExport >= this.exportIntervalSamples) {\n this.exportNewData();\n this.samplesSinceLastExport = 0;\n }\n }\n return true;\n }\n\n mergeBuffers(bufferArray, recLength) {\n const result = new Float32Array(recLength);\n let offset = 0;\n for (let i = 0; i < bufferArray.length; i++) {\n result.set(bufferArray[i], offset);\n offset += bufferArray[i].length;\n }\n return result;\n }\n\n floatTo16BitPCM(input) {\n const output = new Int16Array(input.length);\n for (let i = 0; i < input.length; i++) {\n const s = Math.max(-1, Math.min(1, input[i]));\n output[i] = s < 0 ? s * 0x8000 : s * 0x7fff;\n }\n console.debug(\n \"Float to 16-bit PCM conversion complete. Output byte length:\",\n output.byteLength,\n );\n return output;\n }\n\n floatTo32BitPCM(input) {\n const output = new Int32Array(input.length);\n for (let i = 0; i < input.length; i++) {\n const s = Math.max(-1, Math.min(1, input[i]));\n output[i] = s < 0 ? s * 0x80000000 : s * 0x7fffffff;\n }\n console.debug(\n \"Float to 32-bit PCM conversion complete. Output byte length:\",\n output.byteLength,\n );\n return output;\n }\n\n resample(samples, targetSampleRate) {\n if (this.recordSampleRate === targetSampleRate) {\n return samples;\n }\n const resampledBuffer = new Float32Array(\n (samples.length * targetSampleRate) / this.recordSampleRate,\n );\n const ratio = this.recordSampleRate / targetSampleRate;\n let offset = 0;\n for (let i = 0; i < resampledBuffer.length; i++) {\n const nextOffset = Math.floor((i + 1) * ratio);\n let accum = 0;\n let count = 0;\n for (let j = offset; j < nextOffset && j < samples.length; j++) {\n accum += samples[j];\n count++;\n }\n resampledBuffer[i] = accum / count;\n offset = nextOffset;\n }\n return resampledBuffer;\n }\n\n async resampleBuffer(buffer, targetSampleRate) {\n if (typeof OfflineAudioContext === \"undefined\") {\n return this.resample(buffer, targetSampleRate);\n }\n\n if (this.recordSampleRate === targetSampleRate) {\n return buffer;\n }\n const offlineContext = new OfflineAudioContext(\n this.numberOfChannels,\n buffer.length,\n this.recordSampleRate,\n );\n const sourceBuffer = offlineContext.createBuffer(\n this.numberOfChannels,\n buffer.length,\n this.recordSampleRate,\n );\n sourceBuffer.copyToChannel(buffer, 0);\n\n const bufferSource = offlineContext.createBufferSource();\n bufferSource.buffer = sourceBuffer;\n bufferSource.connect(offlineContext.destination);\n bufferSource.start();\n\n const renderedBuffer = await offlineContext.startRendering();\n\n const resampledBuffer = new Float32Array(renderedBuffer.length);\n renderedBuffer.copyFromChannel(resampledBuffer, 0);\n\n return resampledBuffer;\n }\n\n async exportNewData() {\n // Calculate the total length of the new recorded buffers\n const length = this.newRecBuffer.reduce(\n (acc, buffer) => acc + buffer.length,\n 0,\n );\n\n // Merge all new recorded buffers into a single buffer\n const mergedBuffer = this.mergeBuffers(this.newRecBuffer, length);\n\n const resampledBuffer = await this.resampleBuffer(\n mergedBuffer,\n this.exportSampleRate,\n );\n\n let finalBuffer = resampledBuffer; // Float32Array\n if (this.recordBitDepth !== this.exportBitDepth) {\n if (this.exportBitDepth === 16) {\n finalBuffer = this.floatTo16BitPCM(resampledBuffer);\n } else if (this.exportBitDepth === 32) {\n finalBuffer = this.floatTo32BitPCM(resampledBuffer);\n }\n }\n\n const originalSize = mergedBuffer.byteLength;\n const resampledSize = resampledBuffer.byteLength;\n const finalSize = finalBuffer.byteLength;\n\n // Clear the new recorded buffers after they have been processed\n this.newRecBuffer.length = 0;\n\n // Post the message to the main thread\n // The first argument is the message data, containing the encoded WAV buffer\n // The second argument is the transfer list, which transfers ownership of the ArrayBuffer\n // to the main thread, avoiding the need to copy the buffer and improving performance\n // this.port.postMessage({ recordedData: encodedWav.buffer, sampleRate: this.recordSampleRate }, [encodedWav.buffer]);\n this.port.postMessage({\n command: \"newData\",\n recordedData: finalBuffer.buffer,\n sampleRate: this.exportSampleRate,\n bitDepth: this.exportBitDepth,\n });\n }\n\n async getAllRecordedData() {\n const length = this.recordedBuffers.reduce(\n (acc, buffer) => acc + buffer.length,\n 0,\n );\n const mergedBuffer = this.mergeBuffers(this.recordedBuffers, length);\n const resampledBuffer = await this.resampleBuffer(\n mergedBuffer,\n this.exportSampleRate,\n );\n // Convert to the desired bit depth if necessary\n let finalBuffer = resampledBuffer;\n if (this.recordBitDepth !== this.exportBitDepth) {\n if (this.exportBitDepth === 16) {\n finalBuffer = this.floatTo16BitPCM(resampledBuffer);\n } else if (this.exportBitDepth === 32) {\n finalBuffer = this.floatTo32BitPCM(resampledBuffer);\n }\n }\n\n const originalSize = mergedBuffer.byteLength;\n const resampledSize = resampledBuffer.byteLength;\n const finalSize = finalBuffer.byteLength;\n\n this.recordedBuffers.length = 0; // Clear the buffers after extraction\n\n return finalBuffer.buffer;\n }\n}\n\nregisterProcessor(\"recorder-processor\", RecorderProcessor);\n";
2
- //# sourceMappingURL=inlineAudioWebWorker.web.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inlineAudioWebWorker.web.d.ts","sourceRoot":"","sources":["../../src/workers/inlineAudioWebWorker.web.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,4/PAiPhC,CAAA"}
@@ -1,243 +0,0 @@
1
- export const InlineAudioWebWorker = `
2
- const DEFAULT_BIT_DEPTH = 32;
3
- const DEFAULT_SAMPLE_RATE = 44100;
4
-
5
- class RecorderProcessor extends AudioWorkletProcessor {
6
- constructor() {
7
- super();
8
- this.recordedBuffers = []; // Float32Array
9
- this.newRecBuffer = []; // Float32Array
10
- this.resampledBuffer = []; // Float32Array
11
- this.exportIntervalSamples = 0;
12
- this.samplesSinceLastExport = 0;
13
- this.recordSampleRate = DEFAULT_SAMPLE_RATE; // To be overwritten
14
- this.exportSampleRate = DEFAULT_SAMPLE_RATE; // To be overwritten
15
- this.recordBitDepth = DEFAULT_BIT_DEPTH; // Default to 32-bit depth
16
- this.exportBitDepth = DEFAULT_BIT_DEPTH; // To be overwritten
17
- this.numberOfChannels = 1; // Default to 1 channel (mono)
18
- this.isRecording = true;
19
- this.port.onmessage = this.handleMessage.bind(this);
20
- }
21
-
22
- handleMessage(event) {
23
- switch (event.data.command) {
24
- case "init":
25
- this.recordSampleRate = event.data.recordSampleRate;
26
- this.exportSampleRate =
27
- event.data.exportSampleRate || event.data.recordSampleRate;
28
- this.exportIntervalSamples =
29
- this.recordSampleRate * (event.data.interval / 1000);
30
- if (event.data.numberOfChannels) {
31
- this.numberOfChannels = event.data.numberOfChannels;
32
- }
33
- if (event.data.recordBitDepth) {
34
- this.recordBitDepth = event.data.recordBitDepth;
35
- }
36
- this.exportBitDepth =
37
- event.data.exportBitDepth || this.recordBitDepth || DEFAULT_BIT_DEPTH;
38
- break;
39
- case "stop":
40
- this.isRecording = false;
41
- this.getAllRecordedData()
42
- .then((fullRecordedData) => {
43
- this.port.postMessage({
44
- command: "recordedData",
45
- recordedData: fullRecordedData,
46
- bitDepth: this.exportBitDepth,
47
- sampleRate: this.exportSampleRate,
48
- });
49
- return fullRecordedData;
50
- })
51
- .catch((error) => {
52
- console.error("Error extracting recorded data:", error);
53
- });
54
- break;
55
- }
56
- }
57
-
58
- process(inputs, outputs, parameters) {
59
- if (!this.isRecording) return true;
60
- const input = inputs[0];
61
- if (input.length > 0) {
62
- const newBuffer = new Float32Array(input[0]);
63
- this.newRecBuffer.push(newBuffer);
64
- this.recordedBuffers.push(newBuffer);
65
- this.samplesSinceLastExport += newBuffer.length;
66
-
67
- if (this.samplesSinceLastExport >= this.exportIntervalSamples) {
68
- this.exportNewData();
69
- this.samplesSinceLastExport = 0;
70
- }
71
- }
72
- return true;
73
- }
74
-
75
- mergeBuffers(bufferArray, recLength) {
76
- const result = new Float32Array(recLength);
77
- let offset = 0;
78
- for (let i = 0; i < bufferArray.length; i++) {
79
- result.set(bufferArray[i], offset);
80
- offset += bufferArray[i].length;
81
- }
82
- return result;
83
- }
84
-
85
- floatTo16BitPCM(input) {
86
- const output = new Int16Array(input.length);
87
- for (let i = 0; i < input.length; i++) {
88
- const s = Math.max(-1, Math.min(1, input[i]));
89
- output[i] = s < 0 ? s * 0x8000 : s * 0x7fff;
90
- }
91
- console.debug(
92
- "Float to 16-bit PCM conversion complete. Output byte length:",
93
- output.byteLength,
94
- );
95
- return output;
96
- }
97
-
98
- floatTo32BitPCM(input) {
99
- const output = new Int32Array(input.length);
100
- for (let i = 0; i < input.length; i++) {
101
- const s = Math.max(-1, Math.min(1, input[i]));
102
- output[i] = s < 0 ? s * 0x80000000 : s * 0x7fffffff;
103
- }
104
- console.debug(
105
- "Float to 32-bit PCM conversion complete. Output byte length:",
106
- output.byteLength,
107
- );
108
- return output;
109
- }
110
-
111
- resample(samples, targetSampleRate) {
112
- if (this.recordSampleRate === targetSampleRate) {
113
- return samples;
114
- }
115
- const resampledBuffer = new Float32Array(
116
- (samples.length * targetSampleRate) / this.recordSampleRate,
117
- );
118
- const ratio = this.recordSampleRate / targetSampleRate;
119
- let offset = 0;
120
- for (let i = 0; i < resampledBuffer.length; i++) {
121
- const nextOffset = Math.floor((i + 1) * ratio);
122
- let accum = 0;
123
- let count = 0;
124
- for (let j = offset; j < nextOffset && j < samples.length; j++) {
125
- accum += samples[j];
126
- count++;
127
- }
128
- resampledBuffer[i] = accum / count;
129
- offset = nextOffset;
130
- }
131
- return resampledBuffer;
132
- }
133
-
134
- async resampleBuffer(buffer, targetSampleRate) {
135
- if (typeof OfflineAudioContext === "undefined") {
136
- return this.resample(buffer, targetSampleRate);
137
- }
138
-
139
- if (this.recordSampleRate === targetSampleRate) {
140
- return buffer;
141
- }
142
- const offlineContext = new OfflineAudioContext(
143
- this.numberOfChannels,
144
- buffer.length,
145
- this.recordSampleRate,
146
- );
147
- const sourceBuffer = offlineContext.createBuffer(
148
- this.numberOfChannels,
149
- buffer.length,
150
- this.recordSampleRate,
151
- );
152
- sourceBuffer.copyToChannel(buffer, 0);
153
-
154
- const bufferSource = offlineContext.createBufferSource();
155
- bufferSource.buffer = sourceBuffer;
156
- bufferSource.connect(offlineContext.destination);
157
- bufferSource.start();
158
-
159
- const renderedBuffer = await offlineContext.startRendering();
160
-
161
- const resampledBuffer = new Float32Array(renderedBuffer.length);
162
- renderedBuffer.copyFromChannel(resampledBuffer, 0);
163
-
164
- return resampledBuffer;
165
- }
166
-
167
- async exportNewData() {
168
- // Calculate the total length of the new recorded buffers
169
- const length = this.newRecBuffer.reduce(
170
- (acc, buffer) => acc + buffer.length,
171
- 0,
172
- );
173
-
174
- // Merge all new recorded buffers into a single buffer
175
- const mergedBuffer = this.mergeBuffers(this.newRecBuffer, length);
176
-
177
- const resampledBuffer = await this.resampleBuffer(
178
- mergedBuffer,
179
- this.exportSampleRate,
180
- );
181
-
182
- let finalBuffer = resampledBuffer; // Float32Array
183
- if (this.recordBitDepth !== this.exportBitDepth) {
184
- if (this.exportBitDepth === 16) {
185
- finalBuffer = this.floatTo16BitPCM(resampledBuffer);
186
- } else if (this.exportBitDepth === 32) {
187
- finalBuffer = this.floatTo32BitPCM(resampledBuffer);
188
- }
189
- }
190
-
191
- const originalSize = mergedBuffer.byteLength;
192
- const resampledSize = resampledBuffer.byteLength;
193
- const finalSize = finalBuffer.byteLength;
194
-
195
- // Clear the new recorded buffers after they have been processed
196
- this.newRecBuffer.length = 0;
197
-
198
- // Post the message to the main thread
199
- // The first argument is the message data, containing the encoded WAV buffer
200
- // The second argument is the transfer list, which transfers ownership of the ArrayBuffer
201
- // to the main thread, avoiding the need to copy the buffer and improving performance
202
- // this.port.postMessage({ recordedData: encodedWav.buffer, sampleRate: this.recordSampleRate }, [encodedWav.buffer]);
203
- this.port.postMessage({
204
- command: "newData",
205
- recordedData: finalBuffer.buffer,
206
- sampleRate: this.exportSampleRate,
207
- bitDepth: this.exportBitDepth,
208
- });
209
- }
210
-
211
- async getAllRecordedData() {
212
- const length = this.recordedBuffers.reduce(
213
- (acc, buffer) => acc + buffer.length,
214
- 0,
215
- );
216
- const mergedBuffer = this.mergeBuffers(this.recordedBuffers, length);
217
- const resampledBuffer = await this.resampleBuffer(
218
- mergedBuffer,
219
- this.exportSampleRate,
220
- );
221
- // Convert to the desired bit depth if necessary
222
- let finalBuffer = resampledBuffer;
223
- if (this.recordBitDepth !== this.exportBitDepth) {
224
- if (this.exportBitDepth === 16) {
225
- finalBuffer = this.floatTo16BitPCM(resampledBuffer);
226
- } else if (this.exportBitDepth === 32) {
227
- finalBuffer = this.floatTo32BitPCM(resampledBuffer);
228
- }
229
- }
230
-
231
- const originalSize = mergedBuffer.byteLength;
232
- const resampledSize = resampledBuffer.byteLength;
233
- const finalSize = finalBuffer.byteLength;
234
-
235
- this.recordedBuffers.length = 0; // Clear the buffers after extraction
236
-
237
- return finalBuffer.buffer;
238
- }
239
- }
240
-
241
- registerProcessor("recorder-processor", RecorderProcessor);
242
- `;
243
- //# sourceMappingURL=inlineAudioWebWorker.web.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inlineAudioWebWorker.web.js","sourceRoot":"","sources":["../../src/workers/inlineAudioWebWorker.web.tsx"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiPnC,CAAA","sourcesContent":["export const InlineAudioWebWorker = `\nconst DEFAULT_BIT_DEPTH = 32;\nconst DEFAULT_SAMPLE_RATE = 44100;\n\nclass RecorderProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.recordedBuffers = []; // Float32Array\n this.newRecBuffer = []; // Float32Array\n this.resampledBuffer = []; // Float32Array\n this.exportIntervalSamples = 0;\n this.samplesSinceLastExport = 0;\n this.recordSampleRate = DEFAULT_SAMPLE_RATE; // To be overwritten\n this.exportSampleRate = DEFAULT_SAMPLE_RATE; // To be overwritten\n this.recordBitDepth = DEFAULT_BIT_DEPTH; // Default to 32-bit depth\n this.exportBitDepth = DEFAULT_BIT_DEPTH; // To be overwritten\n this.numberOfChannels = 1; // Default to 1 channel (mono)\n this.isRecording = true;\n this.port.onmessage = this.handleMessage.bind(this);\n }\n\n handleMessage(event) {\n switch (event.data.command) {\n case \"init\":\n this.recordSampleRate = event.data.recordSampleRate;\n this.exportSampleRate =\n event.data.exportSampleRate || event.data.recordSampleRate;\n this.exportIntervalSamples =\n this.recordSampleRate * (event.data.interval / 1000);\n if (event.data.numberOfChannels) {\n this.numberOfChannels = event.data.numberOfChannels;\n }\n if (event.data.recordBitDepth) {\n this.recordBitDepth = event.data.recordBitDepth;\n }\n this.exportBitDepth =\n event.data.exportBitDepth || this.recordBitDepth || DEFAULT_BIT_DEPTH;\n break;\n case \"stop\":\n this.isRecording = false;\n this.getAllRecordedData()\n .then((fullRecordedData) => {\n this.port.postMessage({\n command: \"recordedData\",\n recordedData: fullRecordedData,\n bitDepth: this.exportBitDepth,\n sampleRate: this.exportSampleRate,\n });\n return fullRecordedData;\n })\n .catch((error) => {\n console.error(\"Error extracting recorded data:\", error);\n });\n break;\n }\n }\n\n process(inputs, outputs, parameters) {\n if (!this.isRecording) return true;\n const input = inputs[0];\n if (input.length > 0) {\n const newBuffer = new Float32Array(input[0]);\n this.newRecBuffer.push(newBuffer);\n this.recordedBuffers.push(newBuffer);\n this.samplesSinceLastExport += newBuffer.length;\n\n if (this.samplesSinceLastExport >= this.exportIntervalSamples) {\n this.exportNewData();\n this.samplesSinceLastExport = 0;\n }\n }\n return true;\n }\n\n mergeBuffers(bufferArray, recLength) {\n const result = new Float32Array(recLength);\n let offset = 0;\n for (let i = 0; i < bufferArray.length; i++) {\n result.set(bufferArray[i], offset);\n offset += bufferArray[i].length;\n }\n return result;\n }\n\n floatTo16BitPCM(input) {\n const output = new Int16Array(input.length);\n for (let i = 0; i < input.length; i++) {\n const s = Math.max(-1, Math.min(1, input[i]));\n output[i] = s < 0 ? s * 0x8000 : s * 0x7fff;\n }\n console.debug(\n \"Float to 16-bit PCM conversion complete. Output byte length:\",\n output.byteLength,\n );\n return output;\n }\n\n floatTo32BitPCM(input) {\n const output = new Int32Array(input.length);\n for (let i = 0; i < input.length; i++) {\n const s = Math.max(-1, Math.min(1, input[i]));\n output[i] = s < 0 ? s * 0x80000000 : s * 0x7fffffff;\n }\n console.debug(\n \"Float to 32-bit PCM conversion complete. Output byte length:\",\n output.byteLength,\n );\n return output;\n }\n\n resample(samples, targetSampleRate) {\n if (this.recordSampleRate === targetSampleRate) {\n return samples;\n }\n const resampledBuffer = new Float32Array(\n (samples.length * targetSampleRate) / this.recordSampleRate,\n );\n const ratio = this.recordSampleRate / targetSampleRate;\n let offset = 0;\n for (let i = 0; i < resampledBuffer.length; i++) {\n const nextOffset = Math.floor((i + 1) * ratio);\n let accum = 0;\n let count = 0;\n for (let j = offset; j < nextOffset && j < samples.length; j++) {\n accum += samples[j];\n count++;\n }\n resampledBuffer[i] = accum / count;\n offset = nextOffset;\n }\n return resampledBuffer;\n }\n\n async resampleBuffer(buffer, targetSampleRate) {\n if (typeof OfflineAudioContext === \"undefined\") {\n return this.resample(buffer, targetSampleRate);\n }\n\n if (this.recordSampleRate === targetSampleRate) {\n return buffer;\n }\n const offlineContext = new OfflineAudioContext(\n this.numberOfChannels,\n buffer.length,\n this.recordSampleRate,\n );\n const sourceBuffer = offlineContext.createBuffer(\n this.numberOfChannels,\n buffer.length,\n this.recordSampleRate,\n );\n sourceBuffer.copyToChannel(buffer, 0);\n\n const bufferSource = offlineContext.createBufferSource();\n bufferSource.buffer = sourceBuffer;\n bufferSource.connect(offlineContext.destination);\n bufferSource.start();\n\n const renderedBuffer = await offlineContext.startRendering();\n\n const resampledBuffer = new Float32Array(renderedBuffer.length);\n renderedBuffer.copyFromChannel(resampledBuffer, 0);\n\n return resampledBuffer;\n }\n\n async exportNewData() {\n // Calculate the total length of the new recorded buffers\n const length = this.newRecBuffer.reduce(\n (acc, buffer) => acc + buffer.length,\n 0,\n );\n\n // Merge all new recorded buffers into a single buffer\n const mergedBuffer = this.mergeBuffers(this.newRecBuffer, length);\n\n const resampledBuffer = await this.resampleBuffer(\n mergedBuffer,\n this.exportSampleRate,\n );\n\n let finalBuffer = resampledBuffer; // Float32Array\n if (this.recordBitDepth !== this.exportBitDepth) {\n if (this.exportBitDepth === 16) {\n finalBuffer = this.floatTo16BitPCM(resampledBuffer);\n } else if (this.exportBitDepth === 32) {\n finalBuffer = this.floatTo32BitPCM(resampledBuffer);\n }\n }\n\n const originalSize = mergedBuffer.byteLength;\n const resampledSize = resampledBuffer.byteLength;\n const finalSize = finalBuffer.byteLength;\n\n // Clear the new recorded buffers after they have been processed\n this.newRecBuffer.length = 0;\n\n // Post the message to the main thread\n // The first argument is the message data, containing the encoded WAV buffer\n // The second argument is the transfer list, which transfers ownership of the ArrayBuffer\n // to the main thread, avoiding the need to copy the buffer and improving performance\n // this.port.postMessage({ recordedData: encodedWav.buffer, sampleRate: this.recordSampleRate }, [encodedWav.buffer]);\n this.port.postMessage({\n command: \"newData\",\n recordedData: finalBuffer.buffer,\n sampleRate: this.exportSampleRate,\n bitDepth: this.exportBitDepth,\n });\n }\n\n async getAllRecordedData() {\n const length = this.recordedBuffers.reduce(\n (acc, buffer) => acc + buffer.length,\n 0,\n );\n const mergedBuffer = this.mergeBuffers(this.recordedBuffers, length);\n const resampledBuffer = await this.resampleBuffer(\n mergedBuffer,\n this.exportSampleRate,\n );\n // Convert to the desired bit depth if necessary\n let finalBuffer = resampledBuffer;\n if (this.recordBitDepth !== this.exportBitDepth) {\n if (this.exportBitDepth === 16) {\n finalBuffer = this.floatTo16BitPCM(resampledBuffer);\n } else if (this.exportBitDepth === 32) {\n finalBuffer = this.floatTo32BitPCM(resampledBuffer);\n }\n }\n\n const originalSize = mergedBuffer.byteLength;\n const resampledSize = resampledBuffer.byteLength;\n const finalSize = finalBuffer.byteLength;\n\n this.recordedBuffers.length = 0; // Clear the buffers after extraction\n\n return finalBuffer.buffer;\n }\n}\n\nregisterProcessor(\"recorder-processor\", RecorderProcessor);\n`\n"]}
@@ -1,9 +0,0 @@
1
- {
2
- "platforms": ["ios", "tvos", "android", "web"],
3
- "ios": {
4
- "modules": ["ExpoAudioStreamModule"]
5
- },
6
- "android": {
7
- "modules": ["net.siteed.audiostream.ExpoAudioStreamModule"]
8
- }
9
- }
@@ -1,5 +0,0 @@
1
- import { ConfigPlugin } from '@expo/config-plugins';
2
- declare const withRecordingPermission: ConfigPlugin<{
3
- microphonePermission: string;
4
- }>;
5
- export default withRecordingPermission;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const config_plugins_1 = require("@expo/config-plugins");
4
- const MICROPHONE_USAGE = 'Allow $(PRODUCT_NAME) to access your microphone';
5
- const withRecordingPermission = (config, existingPerms) => {
6
- if (!existingPerms) {
7
- console.warn('No previous permissions provided');
8
- }
9
- config = (0, config_plugins_1.withInfoPlist)(config, (config) => {
10
- config.modResults['NSMicrophoneUsageDescription'] = MICROPHONE_USAGE;
11
- // Add audio to UIBackgroundModes to allow background audio recording
12
- const existingBackgroundModes = config.modResults.UIBackgroundModes || [];
13
- if (!existingBackgroundModes.includes('audio')) {
14
- existingBackgroundModes.push('audio');
15
- }
16
- config.modResults.UIBackgroundModes = existingBackgroundModes;
17
- return config;
18
- });
19
- config = (0, config_plugins_1.withAndroidManifest)(config, (config) => {
20
- const mainApplication = config_plugins_1.AndroidConfig.Manifest.getMainApplicationOrThrow(config.modResults);
21
- config_plugins_1.AndroidConfig.Manifest.addMetaDataItemToMainApplication(mainApplication, 'android.permission.RECORD_AUDIO', MICROPHONE_USAGE);
22
- // Add FOREGROUND_SERVICE permission for handling background recording
23
- config_plugins_1.AndroidConfig.Manifest.addMetaDataItemToMainApplication(mainApplication, 'android.permission.FOREGROUND_SERVICE', 'This apps needs access to the foreground service to record audio in the background');
24
- return config;
25
- });
26
- return config;
27
- };
28
- exports.default = withRecordingPermission;
@@ -1,53 +0,0 @@
1
- import {
2
- AndroidConfig,
3
- ConfigPlugin,
4
- withAndroidManifest,
5
- withInfoPlist,
6
- } from '@expo/config-plugins'
7
-
8
- const MICROPHONE_USAGE = 'Allow $(PRODUCT_NAME) to access your microphone'
9
-
10
- const withRecordingPermission: ConfigPlugin<{
11
- microphonePermission: string
12
- }> = (config, existingPerms) => {
13
- if (!existingPerms) {
14
- console.warn('No previous permissions provided')
15
- }
16
- config = withInfoPlist(config, (config) => {
17
- config.modResults['NSMicrophoneUsageDescription'] = MICROPHONE_USAGE
18
-
19
- // Add audio to UIBackgroundModes to allow background audio recording
20
- const existingBackgroundModes =
21
- config.modResults.UIBackgroundModes || []
22
- if (!existingBackgroundModes.includes('audio')) {
23
- existingBackgroundModes.push('audio')
24
- }
25
- config.modResults.UIBackgroundModes = existingBackgroundModes
26
-
27
- return config
28
- })
29
-
30
- config = withAndroidManifest(config, (config) => {
31
- const mainApplication =
32
- AndroidConfig.Manifest.getMainApplicationOrThrow(config.modResults)
33
-
34
- AndroidConfig.Manifest.addMetaDataItemToMainApplication(
35
- mainApplication,
36
- 'android.permission.RECORD_AUDIO',
37
- MICROPHONE_USAGE
38
- )
39
-
40
- // Add FOREGROUND_SERVICE permission for handling background recording
41
- AndroidConfig.Manifest.addMetaDataItemToMainApplication(
42
- mainApplication,
43
- 'android.permission.FOREGROUND_SERVICE',
44
- 'This apps needs access to the foreground service to record audio in the background'
45
- )
46
-
47
- return config
48
- })
49
-
50
- return config
51
- }
52
-
53
- export default withRecordingPermission
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "expo-module-scripts/tsconfig.plugin",
3
- "compilerOptions": {
4
- "outDir": "build",
5
- "rootDir": "src"
6
- },
7
- "include": ["./src"],
8
- "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9
- }
package/publish.sh DELETED
@@ -1,8 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
- # Bump version
4
- yarn version patch
5
- version=$(node -p "require('./package.json').version")
6
- git add .
7
- git commit -m 'feat: bump version to $version'
8
- yarn clean && yarn prepare && npm publish
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "expo-module-scripts/tsconfig.base",
3
- "compilerOptions": {
4
- "outDir": "./build",
5
- "types": ["jest", "node"],
6
- "typeRoots": [
7
- "./ts-declarations",
8
- "./node_modules/@types",
9
- "../../node_modules/@types",
10
- ],
11
- },
12
- "include": ["./src"],
13
- "exclude": ["**/__mocks__/*", "**/__tests__/*"]
14
- }