Sounds like a piano, sounds like a piano

Source: Internet
Author: User

Sounds like a piano, sounds like a piano

 

:

When you click the button, the corresponding piano sound is played.

This code needs to be imported into AudioToolbox. framework.

This is the project directory:

RootViewController. h

# Import <UIKit/UIKit. h> // Add the header file # import <AudioToolbox/AudioToolbox. h> @ interface RootViewController: UIViewController {NSString * soundFile;} @ end

 

RootViewController. m

- (void)viewDidLoad{    [super viewDidLoad];    // Do any additional setup after loading the view.        NSArray *titleArray=[[NSArray alloc]initWithObjects:@"DO",@"RE",@"MI",@"FA",@"SO",@"LA",@"SI",@"C",@"D",@"E",@"F",@"G", nil];        for (int i=0; i<12; i++) {        UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(50, 80+30*i, 70, 20)];        [button setTitle:[titleArray objectAtIndex:i] forState:UIControlStateNormal];        [button addTarget:self action:@selector(doClickAction:) forControlEvents:UIControlEventTouchUpInside];        button.tag=i;        button.backgroundColor=[UIColor redColor];        [self.view addSubview:button];    }    }#pragma -mark -fucntions-(void)playSound:(NSString*)soundKey{        NSString *path = [NSString stringWithFormat:@"%@%@",[[NSBundle mainBundle] resourcePath],soundKey];    SystemSoundID soundID;    NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];    AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);    AudioServicesPlaySystemSound(soundID);    }#pragma -makr -doClickActions-(void)doClickAction:(UIButton *)btn{    NSLog(@"---doClickActions--");    NSLog(@"--btn.tag---%i",btn.tag);        if (btn.tag==0) {        soundFile = [NSString stringWithFormat:@"/001.mp3"];        [self playSound: soundFile];    }else if (btn.tag==1){        soundFile = [NSString stringWithFormat:@"/002.mp3"];        [self playSound: soundFile];    }else if (btn.tag==2){        soundFile = [NSString stringWithFormat:@"/003.mp3"];        [self playSound: soundFile];    }else if (btn.tag==3){        soundFile = [NSString stringWithFormat:@"/004.mp3"];        [self playSound: soundFile];    }else if (btn.tag==4){        soundFile = [NSString stringWithFormat:@"/005.mp3"];        [self playSound: soundFile];    }else if (btn.tag==5){        soundFile = [NSString stringWithFormat:@"/006.mp3"];        [self playSound: soundFile];    }else if (btn.tag==6){        soundFile = [NSString stringWithFormat:@"/007.mp3"];        [self playSound: soundFile];    }else if (btn.tag==7){        soundFile = [NSString stringWithFormat:@"/C.mp3"];        [self playSound: soundFile];    }else if (btn.tag==8){        soundFile = [NSString stringWithFormat:@"/D.mp3"];        [self playSound: soundFile];    }else if (btn.tag==9){        soundFile = [NSString stringWithFormat:@"/E.mp3"];        [self playSound: soundFile];    }else if (btn.tag==10){        soundFile = [NSString stringWithFormat:@"/F.mp3"];        [self playSound: soundFile];    }else if (btn.tag==11){        soundFile = [NSString stringWithFormat:@"/G.mp3"];        [self playSound: soundFile];    }}

 


I want to buy an electronic piano, which sounds like a piano.

I want to know what you did, whether you want to learn piano or just want to play the keyboard. If you just want to play it, you can use the keyboard. The keyboard also has the piano tone, but the effect is not very good, especially cheap. To be honest, about 1000 of the price is too low for the keyboard. We recommend that you consider over 2000 of the price.

If you want to replace the piano for the time being, do not buy it. Instead, you can directly go to the piano to practice, and buy a real steel after you have money, ordinary Real Steel more than points (second-hand and first-hand 7, that is not recommended ). If you really want to buy it, the minimum number of steel is 3000. However, the difference between cheap steel and Real Steel is still very big. If you want to play the piano in the future, it is really strongly recommended that you do not use the current steel. If you just want to find something close to the piano to play, instead of learning anything from the beginning, then 3000 of the steel. The keyboard is not suitable for your needs. Electric steel is an imitation of the piano, so the number of keyboards is the same as that of the piano, but the tone of the ordinary electronic steel cannot be compared with the real steel.

In fact, we can't talk about the comparison with zhengang. Whether it's an electronic piano or an electronic steel, Their piano sounds are all sampled from zhengang. If it's stanwei, the effect is naturally better (but the mechanical sound is still different from that of the electronics ==). If it is made in Mendelson, then the difference may be big, the comparison between good and bad is true for piano and piano. It's hard to say that I have touched a steel that is not too advanced and cannot compare it. I don't know how the electric steel feels, but if I just add weight, I mean there is still a difference between it and the true string .. If you are not planning to buy a real steel in the past one or two years, it is appropriate to buy an electric steel. However, if you are planning to buy it, I can say that the money is not cost-effective ..

Imitating piano sound Software

Www.gougou.com/..tern%0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.