سؤال

أنا أقوم بعمل تطبيق اختبار للبيانو ، كل لوحة المفاتيح تبدو الآن تلعب ملاحظات قمت بتسجيلها باستخدام Garage Band ، لكن لدي بعض المشكلات:

-يبلغ طول الملاحظات 5 ثوانٍ (الحد الأدنى لوقت الجراج) ، لذلك لا يمكن تكرار الملاحظة ، يجب أن أنتظر حتى الملاحظة الفعلية حوالي 1 ثانية ثم الصمت لنحو 4 ثوانٍ ، وأيضًا لا يمكن تشغيل الملاحظات كما هو متوقع ، أنا أستخدم avfoundation.framework ،،

  • تمت تجربته مع Audiotoolbox.framework ، لكنه يعطي مشاكل مع جهاز iPod 4.1 (لا يعمل !!) ولكن في المحاكاة تبدو جيدة

  • لقد راجعت أيضًا Openal ، وموضوعية ، لكن يبدو أن الكثير من الملاحظات؟

هنا الرمز

 #import "pianoViewController.h"

 @implementation pianoViewController

 @synthesize myMusic;

 @synthesize myMusic2;

 @synthesize myMusic3;

 @synthesize myMusic4;

 @synthesize myMusic5;

 @synthesize myMusic6;

 @synthesize myMusic7;

 @synthesize myMusic8;

 @synthesize myMusic9;

 @synthesize myMusic10;

 @synthesize myMusic11;

 @synthesize myMusic12;




 -(IBAction)Play{

[myMusic play];

  }


 -(IBAction)Play2{

[myMusic2 play];

  } 
  .
  .
  .


  - (void)viewDidLoad {


NSString *pathToMusicFile = [[NSBundle mainBundle] pathForResource:@"c3" ofType:@"aif"];


myMusic = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile] error:NULL];


myMusic.delegate = self; 

myMusic.numberOfLoops = 0;

myMusic.volume = 1.0;


NSString *pathToMusicFile2 = [[NSBundle mainBundle] pathForResource:@"c#" ofType:@"aif"];



myMusic2 = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile2] error:NULL];


myMusic2.delegate = self; 

myMusic2.numberOfLoops = 0;

myMusic2.volume = 1.0;


NSString *pathToMusicFile3 = [[NSBundle mainBundle] pathForResource:@"d" ofType:@"aif"];



myMusic3 = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile3] error:NULL];


myMusic3.delegate = self; 

myMusic3.numberOfLoops = 0;

myMusic3.volume = 1.0;


//[super viewDidLoad];


NSString *pathToMusicFile4 = [[NSBundle mainBundle] pathForResource:@"d#" ofType:@"aif"];



myMusic4 = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile4] error:NULL];


myMusic4.delegate = self; 

myMusic4.numberOfLoops = 0;

myMusic4.volume = 1.0;


//[super viewDidLoad];


  NSString *pathToMusicFile5 = [[NSBundle mainBundle] pathForResource:@"e" ofType:@"aif"];



myMusic5 = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile5] error:NULL];


myMusic5.delegate = self; 

myMusic5.numberOfLoops = 0;

myMusic5.volume = 1.0;


NSString *pathToMusicFile6 = [[NSBundle mainBundle] pathForResource:@"f" ofType:@"aif"];



myMusic6 = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile6] error:NULL];


myMusic6.delegate = self; 

myMusic6.numberOfLoops = 0;

myMusic6.volume = 1.0;


NSString *pathToMusicFile7 = [[NSBundle mainBundle] pathForResource:@"f#" ofType:@"aif"];



myMusic7 = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile7] error:NULL];


myMusic7.delegate = self; 

myMusic7.numberOfLoops = 0;

myMusic7.volume = 1.0;


NSString *pathToMusicFile8 = [[NSBundle mainBundle] pathForResource:@"g" ofType:@"aif"];



myMusic8 = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile8] error:NULL];


myMusic8.delegate = self; 

myMusic8.numberOfLoops = 0;

myMusic8.volume = 1.0;


NSString *pathToMusicFile9 = [[NSBundle mainBundle] pathForResource:@"g#" ofType:@"aif"];



myMusic9 = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile9] error:NULL];


myMusic9.delegate = self; 

myMusic9.numberOfLoops = 0;

myMusic9.volume = 1.0;


NSString *pathToMusicFile10 = [[NSBundle mainBundle] pathForResource:@"a" ofType:@"aif"];



myMusic10 = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile10] error:NULL];


myMusic10.delegate = self; 

myMusic10.numberOfLoops = 0;

myMusic10.volume = 1.0;


NSString *pathToMusicFile11 = [[NSBundle mainBundle] pathForResource:@"a#" ofType:@"aif"];



myMusic11 = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile11] error:NULL];


myMusic11.delegate = self; 

myMusic11.numberOfLoops = 0;

myMusic11.volume = 1.0;


NSString *pathToMusicFile12 = [[NSBundle mainBundle] pathForResource:@"b" ofType:@"aif"];



myMusic12 = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile12] error:NULL];


myMusic12.delegate = self; 

myMusic12.numberOfLoops = 0;

myMusic12.volume = 1.0;










[super viewDidLoad];

}






// Override to allow orientations other than the default portrait orientation.
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
 }


  - (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
 }

  - (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
 }


   - (void)dealloc {
[super dealloc];
 }

 @end

فهل هناك طريقة حتى أتمكن من استخدام Avfoundation لتشغيل ملاحظات متعددة بسرعة؟ (متداخلة تقريبًا مثل Audiotoolbox) أو ماذا تقترح؟

شكرا لك!

هل كانت مفيدة؟

المحلول

بدلاً من تسجيل الأحذية في إصلاح لشيء لا ينبغي أن يكون مشكلة ، أقترح بدلاً من ذلك أنك تستخدم بعض برامج تحرير الصوت التي لا تحتوي على الحد الأدنى لقيود طول المسار.

أحد الأمثلة على ذلك ، وهو Mac متوافق ومجاني ، هو الجرأة: http://audacity.sourceforge.net/

أيضا ، Openal مثالية للعب الكثير من الأصوات القصيرة ، وربما متداخلة. أعتقد أنه يمكنك الحصول على 32 اللعب في وقت واحد إذا أردت.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top