Currently I am trying to send a 16 kbps PCM file and also trying to make sure that the data size is a multiple of 4 since it will make flash writing easier.
Context
So I made the file into a .caf and when I typed afinfo wave_16.caf in the terminal it shows this.
File type ID: caff
Num Tracks: 1
----
Data format: 2 ch, 8000 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
no channel layout.
estimated duration: 10.997500 sec
audio bytes: 22418
audio packets: 88
bit rate: 15921 bits per second
packet size upper bound: 374
maximum packet size: 374
audio data file offset: 4096
optimized
audio 87980 valid frames + 2112 priming + 20 remainder = 90112
source bit depth: I16
----
Code
What I have so far in xcode is:
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"wave_16" ofType:@"caf"];
NSFileHandle * soundFile = [NSFileHandle fileHandleForReadingAtPath:soundPath];
[soundFile seekToEndOfFile];
NSData *data = [soundFile readDataOfLength:4];
NSURL *soundPathURL = [NSURL fileURLWithPath:soundPath];
self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundPathURL error:nil];
self.audioPlayer.delegate = self;
self.audioPlayer.numberOfLoops = -1;
[_activeDevice writeValue:data toCharacteristic:_activeCharacteristic
completion:^(id obj, BOOL completed) {}];
I am wondering if this actually achieves what I want? I have the sound playing in the background when I load the app, so I know the path is correct (testing purposes). I want to know if this sends the PCM file to the BLE? or am I totally off?
I can provide more context if needed
Aucun commentaire:
Enregistrer un commentaire