我正在尝试使用这个项目,它是我正在构建的 iPhone 应用程序的 Objective-C 合成器。但是,我在MHAudioBufferPlayer
上课时遇到了麻烦。
在MHAudioBufferPlayer.m
课堂上,我收到一堆关于、和的Use of undeclared identifier
错误。这是有道理的,因为这些标识符从来没有在它们前面使用下划线声明。但是,它们在类中声明时没有下划线。_gain
_playing
_audioFormat
MHAudioBufferPlayer.h
由于我是 Objective-C 的新手,所以我对此感到有些困惑。下划线是否表示要采取的特殊行动?它应该被翻译成self.gain
,self.playing
等吗?我怎样才能解决这个问题?或者这段代码只是错误的?
- (id)initWithSampleRate:(Float64)sampleRate channels:(UInt32)channels bitsPerChannel:(UInt32)bitsPerChannel packetsPerBuffer:(UInt32)packetsPerBuffer
{
if ((self = [super init]))
{
_playing = NO;
_playQueue = NULL;
_gain = 1.0;
_audioFormat.mFormatID = kAudioFormatLinearPCM;
_audioFormat.mSampleRate = sampleRate;
_audioFormat.mChannelsPerFrame = channels;
_audioFormat.mBitsPerChannel = bitsPerChannel;
_audioFormat.mFramesPerPacket = 1; // uncompressed audio
_audioFormat.mBytesPerFrame = _audioFormat.mChannelsPerFrame * _audioFormat.mBitsPerChannel/8;
_audioFormat.mBytesPerPacket = _audioFormat.mBytesPerFrame * _audioFormat.mFramesPerPacket;
_audioFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
_packetsPerBuffer = packetsPerBuffer;
_bytesPerBuffer = _packetsPerBuffer * _audioFormat.mBytesPerPacket;
[self setUpAudio];
}
return self;
}