@siteed/expo-audio-studio 2.6.0 → 2.6.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.
- package/CHANGELOG.md +10 -1
- package/android/src/main/java/net/siteed/audiostream/ExpoAudioStreamModule.kt +2 -2
- package/android/src/main/java/net/siteed/audiostream/LogUtils.kt +3 -3
- package/build/ExpoAudioStream.types.d.ts +5 -1
- package/build/ExpoAudioStream.types.d.ts.map +1 -1
- package/build/ExpoAudioStream.types.js.map +1 -1
- package/build/useAudioRecorder.d.ts.map +1 -1
- package/build/useAudioRecorder.js +1 -1
- package/build/useAudioRecorder.js.map +1 -1
- package/ios/AudioDeviceManager.swift +65 -65
- package/ios/AudioProcessor.swift +32 -32
- package/ios/AudioStreamManager.swift +323 -158
- package/ios/ExpoAudioStreamModule.swift +92 -75
- package/ios/ISSUE_IOS.md +26 -3
- package/ios/Logger.swift +27 -7
- package/package.json +1 -1
- package/src/ExpoAudioStream.types.ts +5 -1
- package/src/useAudioRecorder.tsx +1 -2
package/ios/AudioProcessor.swift
CHANGED
|
@@ -286,7 +286,7 @@ public class AudioProcessor {
|
|
|
286
286
|
numberOfChannels: Int
|
|
287
287
|
) -> AudioAnalysisData? {
|
|
288
288
|
guard !data.isEmpty else {
|
|
289
|
-
Logger.debug("Data is empty, rejecting")
|
|
289
|
+
Logger.debug("AudioProcessor", "Data is empty, rejecting")
|
|
290
290
|
reject("DATA_EMPTY", "The audio data is empty.")
|
|
291
291
|
return nil
|
|
292
292
|
}
|
|
@@ -305,7 +305,7 @@ public class AudioProcessor {
|
|
|
305
305
|
return int32Pointer.map { Float($0) / Float(Int32.max) }
|
|
306
306
|
}
|
|
307
307
|
default:
|
|
308
|
-
Logger.debug("Unsupported bit depth. Rejecting")
|
|
308
|
+
Logger.debug("AudioProcessor", "Unsupported bit depth. Rejecting")
|
|
309
309
|
reject("UNSUPPORTED_BIT_DEPTH", "Unsupported bit depth: \(bitDepth)")
|
|
310
310
|
return nil
|
|
311
311
|
}
|
|
@@ -337,7 +337,7 @@ public class AudioProcessor {
|
|
|
337
337
|
bitDepth: Int,
|
|
338
338
|
numberOfChannels: Int
|
|
339
339
|
) -> AudioAnalysisData? {
|
|
340
|
-
Logger.debug("Processing audio data with sample rate: \(sampleRate), segmentDurationMs: \(segmentDurationMs), bitDepth: \(bitDepth), numberOfChannels: \(numberOfChannels)")
|
|
340
|
+
Logger.debug("AudioProcessor", "Processing audio data with sample rate: \(sampleRate), segmentDurationMs: \(segmentDurationMs), bitDepth: \(bitDepth), numberOfChannels: \(numberOfChannels)")
|
|
341
341
|
|
|
342
342
|
let startTime = CACurrentMediaTime()
|
|
343
343
|
|
|
@@ -385,7 +385,7 @@ public class AudioProcessor {
|
|
|
385
385
|
let endTime = CACurrentMediaTime()
|
|
386
386
|
let processingTimeMs = Float((endTime - startTime) * 1000)
|
|
387
387
|
|
|
388
|
-
Logger.debug("Processed \(dataPoints.count) data points in \(processingTimeMs) ms")
|
|
388
|
+
Logger.debug("AudioProcessor", "Processed \(dataPoints.count) data points in \(processingTimeMs) ms")
|
|
389
389
|
|
|
390
390
|
return AudioAnalysisData(
|
|
391
391
|
segmentDurationMs: segmentDurationMs,
|
|
@@ -511,7 +511,7 @@ public class AudioProcessor {
|
|
|
511
511
|
featureOptions: [String: Bool]
|
|
512
512
|
) -> AudioAnalysisData? {
|
|
513
513
|
guard let audioFile = audioFile else {
|
|
514
|
-
Logger.debug("No audio file loaded")
|
|
514
|
+
Logger.debug("AudioProcessor", "No audio file loaded")
|
|
515
515
|
return nil
|
|
516
516
|
}
|
|
517
517
|
|
|
@@ -527,7 +527,7 @@ public class AudioProcessor {
|
|
|
527
527
|
|
|
528
528
|
// Validate frame range
|
|
529
529
|
guard startFrame >= 0 && endFrame <= audioFile.length && startFrame < endFrame else {
|
|
530
|
-
Logger.debug("Invalid time range")
|
|
530
|
+
Logger.debug("AudioProcessor", "Invalid time range")
|
|
531
531
|
return nil
|
|
532
532
|
}
|
|
533
533
|
|
|
@@ -535,7 +535,7 @@ public class AudioProcessor {
|
|
|
535
535
|
let framesPerBuffer = AVAudioFrameCount(Float(sampleRate) * Float(segmentDurationMs) / 1000.0)
|
|
536
536
|
|
|
537
537
|
guard let buffer = AVAudioPCMBuffer(pcmFormat: audioFile.processingFormat, frameCapacity: framesPerBuffer) else {
|
|
538
|
-
Logger.debug("Failed to create buffer")
|
|
538
|
+
Logger.debug("AudioProcessor", "Failed to create buffer")
|
|
539
539
|
return nil
|
|
540
540
|
}
|
|
541
541
|
|
|
@@ -613,7 +613,7 @@ public class AudioProcessor {
|
|
|
613
613
|
dataPoints.append(dataPoint)
|
|
614
614
|
currentId += 1
|
|
615
615
|
} catch {
|
|
616
|
-
Logger.debug("Error reading audio data: \(error)")
|
|
616
|
+
Logger.debug("AudioProcessor", "Error reading audio data: \(error)")
|
|
617
617
|
return nil
|
|
618
618
|
}
|
|
619
619
|
|
|
@@ -656,20 +656,20 @@ public class AudioProcessor {
|
|
|
656
656
|
progressCallback: ((Float, Int64, Int64) -> Void)? = nil
|
|
657
657
|
) -> TrimResult? {
|
|
658
658
|
// Log the input parameters
|
|
659
|
-
Logger.debug("Starting audio trim operation:")
|
|
660
|
-
Logger.debug("- Mode: \(mode)")
|
|
659
|
+
Logger.debug("AudioProcessor", "Starting audio trim operation:")
|
|
660
|
+
Logger.debug("AudioProcessor", "- Mode: \(mode)")
|
|
661
661
|
if let start = startTimeMs, let end = endTimeMs {
|
|
662
|
-
Logger.debug("- Time range: \(start)ms to \(end)ms")
|
|
662
|
+
Logger.debug("AudioProcessor", "- Time range: \(start)ms to \(end)ms")
|
|
663
663
|
}
|
|
664
664
|
if let ranges = ranges {
|
|
665
|
-
Logger.debug("- Ranges count: \(ranges.count)")
|
|
665
|
+
Logger.debug("AudioProcessor", "- Ranges count: \(ranges.count)")
|
|
666
666
|
}
|
|
667
667
|
|
|
668
668
|
// Log output format details
|
|
669
669
|
if let format = outputFormat {
|
|
670
670
|
let formatType = format["format"] as? String ?? "unknown"
|
|
671
671
|
let bitrate = format["bitrate"] as? Int ?? 0
|
|
672
|
-
Logger.debug("- Output format: \(formatType), bitrate: \(bitrate)")
|
|
672
|
+
Logger.debug("AudioProcessor", "- Output format: \(formatType), bitrate: \(bitrate)")
|
|
673
673
|
}
|
|
674
674
|
|
|
675
675
|
guard let audioFile = audioFile else { return nil }
|
|
@@ -696,7 +696,7 @@ public class AudioProcessor {
|
|
|
696
696
|
let formatStr = validFormats.contains(requestedFormat.lowercased()) ? requestedFormat.lowercased() : "aac"
|
|
697
697
|
|
|
698
698
|
if formatStr != requestedFormat.lowercased() {
|
|
699
|
-
Logger.debug("Unsupported format '\(requestedFormat)', falling back to 'aac'")
|
|
699
|
+
Logger.debug("AudioProcessor", "Unsupported format '\(requestedFormat)', falling back to 'aac'")
|
|
700
700
|
}
|
|
701
701
|
|
|
702
702
|
let targetSampleRate = outputFormat?["sampleRate"] as? Double ?? inputSampleRate
|
|
@@ -747,14 +747,14 @@ public class AudioProcessor {
|
|
|
747
747
|
}
|
|
748
748
|
|
|
749
749
|
// When creating the output file
|
|
750
|
-
Logger.debug("Creating output file at: \(outputURL.path)")
|
|
750
|
+
Logger.debug("AudioProcessor", "Creating output file at: \(outputURL.path)")
|
|
751
751
|
|
|
752
752
|
// After processing is complete
|
|
753
|
-
Logger.debug("Trim operation completed")
|
|
754
|
-
Logger.debug("- Output file: \(outputURL.path)")
|
|
755
|
-
Logger.debug("- File exists: \(FileManager.default.fileExists(atPath: outputURL.path))")
|
|
756
|
-
Logger.debug("- File size: \(try? FileManager.default.attributesOfItem(atPath: outputURL.path)[.size] as? Int64 ?? 0) bytes")
|
|
757
|
-
Logger.debug("- File extension: \(outputURL.pathExtension)")
|
|
753
|
+
Logger.debug("AudioProcessor", "Trim operation completed")
|
|
754
|
+
Logger.debug("AudioProcessor", "- Output file: \(outputURL.path)")
|
|
755
|
+
Logger.debug("AudioProcessor", "- File exists: \(FileManager.default.fileExists(atPath: outputURL.path))")
|
|
756
|
+
Logger.debug("AudioProcessor", "- File size: \(try? FileManager.default.attributesOfItem(atPath: outputURL.path)[.size] as? Int64 ?? 0) bytes")
|
|
757
|
+
Logger.debug("AudioProcessor", "- File extension: \(outputURL.pathExtension)")
|
|
758
758
|
|
|
759
759
|
return createTrimResult(from: outputURL, keepRanges: keepRanges, formatStr: formatStr, sampleRate: Int(inputSampleRate), channels: inputChannels, bitDepth: 16, bitrate: bitrate)
|
|
760
760
|
} else {
|
|
@@ -830,14 +830,14 @@ public class AudioProcessor {
|
|
|
830
830
|
// Find closest supported sample rate
|
|
831
831
|
if !supportedSampleRates.contains(sampleRate) {
|
|
832
832
|
let closestRate = supportedSampleRates.min(by: { abs($0 - sampleRate) < abs($1 - sampleRate) }) ?? 44100.0
|
|
833
|
-
Logger.debug("Unsupported sample rate \(sampleRate)Hz for AAC, using closest supported rate: \(closestRate)Hz")
|
|
833
|
+
Logger.debug("AudioProcessor", "Unsupported sample rate \(sampleRate)Hz for AAC, using closest supported rate: \(closestRate)Hz")
|
|
834
834
|
sampleRate = closestRate
|
|
835
835
|
}
|
|
836
836
|
|
|
837
837
|
// Validate channels (AAC typically supports 1 or 2 channels)
|
|
838
838
|
var channels = outputFormat?["channels"] as? Int ?? 2
|
|
839
839
|
if channels > 2 {
|
|
840
|
-
Logger.debug("AAC encoding doesn't support \(channels) channels, limiting to 2 channels")
|
|
840
|
+
Logger.debug("AudioProcessor", "AAC encoding doesn't support \(channels) channels, limiting to 2 channels")
|
|
841
841
|
channels = 2
|
|
842
842
|
} else if channels < 1 {
|
|
843
843
|
channels = 1
|
|
@@ -846,10 +846,10 @@ public class AudioProcessor {
|
|
|
846
846
|
// Validate bitrate (AAC typically supports 8000-320000 bps)
|
|
847
847
|
var bitrate = outputFormat?["bitrate"] as? Int ?? 128000
|
|
848
848
|
if bitrate < 8000 {
|
|
849
|
-
Logger.debug("AAC bitrate too low, setting to minimum 8000 bps")
|
|
849
|
+
Logger.debug("AudioProcessor", "AAC bitrate too low, setting to minimum 8000 bps")
|
|
850
850
|
bitrate = 8000
|
|
851
851
|
} else if bitrate > 320000 {
|
|
852
|
-
Logger.debug("AAC bitrate too high, setting to maximum 320000 bps")
|
|
852
|
+
Logger.debug("AudioProcessor", "AAC bitrate too high, setting to maximum 320000 bps")
|
|
853
853
|
bitrate = 320000
|
|
854
854
|
}
|
|
855
855
|
|
|
@@ -863,7 +863,7 @@ public class AudioProcessor {
|
|
|
863
863
|
]
|
|
864
864
|
fileType = .m4a
|
|
865
865
|
|
|
866
|
-
Logger.debug("""
|
|
866
|
+
Logger.debug("AudioProcessor", """
|
|
867
867
|
Configuring AAC output:
|
|
868
868
|
- Container: m4a
|
|
869
869
|
- Format: AAC
|
|
@@ -939,7 +939,7 @@ public class AudioProcessor {
|
|
|
939
939
|
}
|
|
940
940
|
|
|
941
941
|
if let error = error {
|
|
942
|
-
Logger.debug("Conversion error: \(error)")
|
|
942
|
+
Logger.debug("AudioProcessor", "Conversion error: \(error)")
|
|
943
943
|
continue
|
|
944
944
|
}
|
|
945
945
|
|
|
@@ -951,7 +951,7 @@ public class AudioProcessor {
|
|
|
951
951
|
}
|
|
952
952
|
|
|
953
953
|
if !writerInput.append(sampleBuffer) {
|
|
954
|
-
Logger.debug("Failed to append sample buffer: \(assetWriter.error?.localizedDescription ?? "Unknown error")")
|
|
954
|
+
Logger.debug("AudioProcessor", "Failed to append sample buffer: \(assetWriter.error?.localizedDescription ?? "Unknown error")")
|
|
955
955
|
}
|
|
956
956
|
}
|
|
957
957
|
|
|
@@ -961,11 +961,11 @@ public class AudioProcessor {
|
|
|
961
961
|
progressCallback?(progress, 0, totalFrames * Int64(inputFormat.streamDescription.pointee.mBytesPerFrame))
|
|
962
962
|
|
|
963
963
|
if framesProcessed % 10000 == 0 { // Log every 10000 frames to avoid excessive logging
|
|
964
|
-
Logger.debug("Processed \(framesProcessed)/\(totalFramesToProcess) frames")
|
|
964
|
+
Logger.debug("AudioProcessor", "Processed \(framesProcessed)/\(totalFramesToProcess) frames")
|
|
965
965
|
}
|
|
966
966
|
|
|
967
967
|
} catch {
|
|
968
|
-
Logger.debug("Error reading audio: \(error)")
|
|
968
|
+
Logger.debug("AudioProcessor", "Error reading audio: \(error)")
|
|
969
969
|
break
|
|
970
970
|
}
|
|
971
971
|
}
|
|
@@ -976,15 +976,15 @@ public class AudioProcessor {
|
|
|
976
976
|
let finishSemaphore = DispatchSemaphore(value: 0)
|
|
977
977
|
assetWriter.finishWriting {
|
|
978
978
|
if let error = assetWriter.error {
|
|
979
|
-
Logger.debug("Error finishing writing: \(error)")
|
|
979
|
+
Logger.debug("AudioProcessor", "Error finishing writing: \(error)")
|
|
980
980
|
} else {
|
|
981
|
-
Logger.debug("Writing finished successfully")
|
|
981
|
+
Logger.debug("AudioProcessor", "Writing finished successfully")
|
|
982
982
|
|
|
983
983
|
// Verify the output file
|
|
984
984
|
let fileExists = FileManager.default.fileExists(atPath: tempOutputURL.path)
|
|
985
985
|
let fileSize = (try? FileManager.default.attributesOfItem(atPath: tempOutputURL.path)[.size] as? Int64) ?? 0
|
|
986
986
|
|
|
987
|
-
Logger.debug("""
|
|
987
|
+
Logger.debug("AudioProcessor", """
|
|
988
988
|
Output file verification:
|
|
989
989
|
- Path: \(tempOutputURL.path)
|
|
990
990
|
- Exists: \(fileExists)
|