2022-02-06 11:08:34 +00:00
|
|
|
//
|
|
|
|
// AudioChunk.h
|
|
|
|
// CogAudio Framework
|
|
|
|
//
|
|
|
|
// Created by Christopher Snowhill on 2/5/22.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef AudioChunk_h
|
|
|
|
#define AudioChunk_h
|
|
|
|
|
|
|
|
#import <CoreAudio/CoreAudio.h>
|
2022-02-07 05:49:27 +00:00
|
|
|
#import <Foundation/Foundation.h>
|
2022-02-06 11:08:34 +00:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2022-02-07 08:56:05 +00:00
|
|
|
enum {
|
|
|
|
AudioChannelFrontLeft = 1 << 0,
|
|
|
|
AudioChannelFrontRight = 1 << 1,
|
|
|
|
AudioChannelFrontCenter = 1 << 2,
|
|
|
|
AudioChannelLFE = 1 << 3,
|
|
|
|
AudioChannelBackLeft = 1 << 4,
|
|
|
|
AudioChannelBackRight = 1 << 5,
|
|
|
|
AudioChannelFrontCenterLeft = 1 << 6,
|
|
|
|
AudioChannelFrontCenterRight = 1 << 7,
|
|
|
|
AudioChannelBackCenter = 1 << 8,
|
|
|
|
AudioChannelSideLeft = 1 << 9,
|
|
|
|
AudioChannelSideRight = 1 << 10,
|
|
|
|
AudioChannelTopCenter = 1 << 11,
|
|
|
|
AudioChannelTopFrontLeft = 1 << 12,
|
|
|
|
AudioChannelTopFrontCenter = 1 << 13,
|
|
|
|
AudioChannelTopFrontRight = 1 << 14,
|
|
|
|
AudioChannelTopBackLeft = 1 << 15,
|
|
|
|
AudioChannelTopBackCenter = 1 << 16,
|
|
|
|
AudioChannelTopBackRight = 1 << 17,
|
|
|
|
|
|
|
|
AudioConfigMono = AudioChannelFrontCenter,
|
|
|
|
AudioConfigStereo = AudioChannelFrontLeft | AudioChannelFrontRight,
|
|
|
|
AudioConfig3Point0 = AudioChannelFrontLeft | AudioChannelFrontRight |
|
|
|
|
AudioChannelFrontCenter,
|
|
|
|
AudioConfig4Point0 = AudioChannelFrontLeft | AudioChannelFrontRight |
|
|
|
|
AudioChannelBackLeft | AudioChannelBackRight,
|
|
|
|
AudioConfig5Point0 = AudioChannelFrontLeft | AudioChannelFrontRight |
|
|
|
|
AudioChannelFrontCenter | AudioChannelBackLeft |
|
|
|
|
AudioChannelBackRight,
|
|
|
|
AudioConfig5Point1 = AudioChannelFrontLeft | AudioChannelFrontRight |
|
|
|
|
AudioChannelFrontCenter | AudioChannelLFE |
|
|
|
|
AudioChannelBackLeft | AudioChannelBackRight,
|
|
|
|
AudioConfig5Point1Side = AudioChannelFrontLeft | AudioChannelFrontRight |
|
|
|
|
AudioChannelFrontCenter | AudioChannelLFE |
|
|
|
|
AudioChannelSideLeft | AudioChannelSideRight,
|
|
|
|
AudioConfig6Point1 = AudioChannelFrontLeft | AudioChannelFrontRight |
|
|
|
|
AudioChannelFrontCenter | AudioChannelLFE |
|
|
|
|
AudioChannelBackCenter | AudioChannelSideLeft |
|
|
|
|
AudioChannelSideRight,
|
|
|
|
AudioConfig7Point1 = AudioChannelFrontLeft | AudioChannelFrontRight |
|
|
|
|
AudioChannelFrontCenter | AudioChannelLFE |
|
|
|
|
AudioChannelBackLeft | AudioChannelBackRight |
|
|
|
|
AudioChannelSideLeft | AudioChannelSideRight,
|
|
|
|
|
|
|
|
AudioChannelsBackLeftRight = AudioChannelBackLeft | AudioChannelBackRight,
|
|
|
|
AudioChannelsSideLeftRight = AudioChannelSideLeft | AudioChannelSideRight,
|
|
|
|
};
|
|
|
|
|
2022-02-06 11:08:34 +00:00
|
|
|
@interface AudioChunk : NSObject {
|
2022-02-07 05:49:27 +00:00
|
|
|
AudioStreamBasicDescription format;
|
|
|
|
NSMutableData *chunkData;
|
2022-02-07 08:56:05 +00:00
|
|
|
uint32_t channelConfig;
|
2022-02-07 05:49:27 +00:00
|
|
|
BOOL formatAssigned;
|
|
|
|
BOOL lossless;
|
2022-07-14 08:45:49 +00:00
|
|
|
BOOL hdcd;
|
2022-02-06 11:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@property AudioStreamBasicDescription format;
|
2022-02-07 08:56:05 +00:00
|
|
|
@property uint32_t channelConfig;
|
2022-02-06 11:08:34 +00:00
|
|
|
@property BOOL lossless;
|
|
|
|
|
2022-02-07 08:56:05 +00:00
|
|
|
+ (uint32_t)guessChannelConfig:(uint32_t)channelCount;
|
|
|
|
+ (uint32_t)channelIndexFromConfig:(uint32_t)channelConfig forFlag:(uint32_t)flag;
|
|
|
|
+ (uint32_t)extractChannelFlag:(uint32_t)index fromConfig:(uint32_t)channelConfig;
|
|
|
|
+ (uint32_t)countChannels:(uint32_t)channelConfig;
|
|
|
|
+ (uint32_t)findChannelIndex:(uint32_t)flag;
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (id)init;
|
2022-07-10 22:14:47 +00:00
|
|
|
- (id)initWithProperties:(NSDictionary *)properties;
|
2022-02-06 11:08:34 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)assignSamples:(const void *)data frameCount:(size_t)count;
|
2022-07-11 21:37:10 +00:00
|
|
|
- (void)assignData:(NSData *)data;
|
2022-02-06 11:08:34 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSData *)removeSamples:(size_t)frameCount;
|
2022-02-06 11:08:34 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (BOOL)isEmpty;
|
2022-02-06 11:08:34 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (size_t)frameCount;
|
2022-07-10 22:14:47 +00:00
|
|
|
- (void)setFrameCount:(size_t)count; // For truncation only
|
2022-02-06 11:08:34 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (double)duration;
|
2022-02-06 11:08:34 +00:00
|
|
|
|
2022-07-14 08:45:49 +00:00
|
|
|
- (BOOL)isHDCD;
|
|
|
|
- (void)setHDCD;
|
|
|
|
|
2022-02-06 11:08:34 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|
|
|
|
|
|
|
|
#endif /* AudioChunk_h */
|