0
私は目標Cを使って8ステップのドラムシーケンサーを作っていますが、キック、スネア、ハットのサンプルをバッファにロードしていますが、シミュレータを実行してスイッチを押すとキックドラムをトグルすると、恐ろしいEXC_BAD_ACCESSエラーが発生し、プログラムが終了します。iOSドラムシーケンサー - バッファの問題(不正なアクセス)
ブレークポイントを入力すると、デバッグウィンドウにバッファに何もないことが示唆されます。しかし、私の知る限りでは、彼らがここにロードされます。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// laod the audio files into memory buffers
_kickBuffer = [PAEBuffer bufferNamed:@"TMD 09 KICK.aif"];
_snareBuffer = [PAEBuffer bufferNamed:@"TMD 09 SN 1.aif"];
_hihatBuffer = [PAEBuffer bufferNamed:@"TMD 09 CHH.aif"];
// initialise the host
_host = [PAEAudioHost audioHostWithNumOutputs:2];
// create some channel strips to play the audio
const int numVoices = 16;
NSMutableArray* channelStrips = [[NSMutableArray alloc] initWithCapacity:numVoices];
for (int i = 0; i < numVoices; ++i)
{
PAEChannelStrip* channelStrip = [PAEChannelStrip channelStripWithNumChannels:2];
[channelStrips addObject:channelStrip];
}
エラーは、この機能
-(void)playBuffer:(PAEBuffer*)buffer
{
PAEBufferPlayer* player = [PAEBufferPlayer bufferPlayerWithBuffer:buffer];
player.loop = NO;
PAEChannelStrip* channelStrip = _channelStrips[_nextVoice];
channelStrip.input = player;
// we allocated voices in a round robin fashion, reallocating the oldest voices first
_nextVoice++;
if (_nextVoice >= _channelStrips.count)
_nextVoice = 0;
}
私はすべてが明らかにされていない場合はとても残念こののlangaugeに新しいですに表示されます。どのような助けも、非常にappriciatedです、ありがとう。
(編集)を追加しましたsetStep機能
// the step has changed
-(void)setStep:(int)step
{
if (step < 0 || step >= NUMSTEPS)
return;
_step = step;
// decide which buffers to play on this step
if (_kickSteps[step])
[self playBuffer:_kickBuffer];
if (_snareSteps[step])
[self playBuffer:_snareBuffer];
if (_hihatSteps[step])
[self playBuffer:_hihatBuffer];
}
'buffer'は' playBuffer: '' nil'に渡されていますか? – JAL
はい、デバッグウィンドウにこのプレーヤーが表示されます\t PAEBufferPlayer * \tなし\t 0x0000000000000000 – Neo
ここで、 'playBuffer'をどこで呼びますか? – JAL