OS X磁盘修复

1、进入单用户模式:同时按Command+S+电源键,直到进入命令行界面。
2、在命令行界面输入:/sbin/fsck -fy
磁盘修复需要几分钟时间。完成后exit重启。

Advertisements

Mac剪贴粘贴快捷键

Command+C
Command+Alt+V

MacPorts试用手记

MacPorts用来把安装一些由Linux上移植到Mac的软件。

下载 https://www.macports.org/install.php
安装 默认在opt/local/etc/目录下
帮助 https://guide.macports.org
帮助 http://trac.macports.org/wiki/howto/PortTreeTarball

第一次使用时要下载软件库的索引文件。用以下命令。-v参数可以显示状态,建议第一次时使用。-d是debug模式。
sudo port -v selfupdate
sudo port -d sync

如上述命令连接时错误,则到以下镜像网址找一个能下载的链接下载。
https://trac.macports.org/wiki/Mirrors
或直接修改${prefix}/etc/macports/sources.conf文件中的链接为
http://www.macports.org/files/ports.tar.gz [default]
或直接将port.tar保存到本地
file:////Users/(…)/ports.tar

使用
port search
sudo port install

Mac OSX显示隐藏文件

输入命令:

显示
defaults write com.apple.finder AppleShowAllFiles 1 && killall Finder

隐藏
defaults write com.apple.finder AppleShowAllFiles 0 && killall Finder

按住alt键右击Finder图标,在弹出菜单中点击Relaunch。

Best Audio Format for iPhone Audio Programming

Trackback: http://www.totodotnet.net/tag/avaudiorecorder/

I had never done audio programming before I started my iPhone programming. After starting iPhone programming, I started to learn CoreAudio Framework, Audio Unit for Mac OS X system and iPhone System, and largest problem is which audio format should I choose for best practice?

After iPhone OS 3.0 beta was released, Apple finally introduced AVAudioRecorder class to AVFoundation framework. With which, we can play and record audio more efficiently! For me, I can cut the original playback code down from 400+ lines to 20 lines. And for recording, cut down from 300+ lines to 30 lines.

When testing AVAudioRecorder, the file format will significantly effect the file size. I had tried all the available data format when packed with .CAF file.  Here is the result:

[Updated@2009-05-25] YES, we can record with this format on simulator, but we CANNOT record this on the device! Remember this. While another one we can refer to is Apple’s official QA1615

[Updated@2009-06-15] Please do not use AAC if you want to play a system sound.

[Updated@2009-09-30] iPhone 3GS support AAC recording since iPhone OS 3.1 was released on Sept 9th. You can use hardware assisted encoding to record the AAC formatted audio file. But let me remind you, you can not use AVAudioRecord to record AAC audio file yet. The only option is using the RemoteIO Unit.

  • kAudioFormatLinearPCM               = ‘lpcm’,    OK    20.2M    .CAF
  • kAudioFormatAppleIMA4               = ‘ima4′,    OK    2.7M     .CAF [Best Choice]
  • kAudioFormatMPEG4AAC                = ‘aac ‘,    OK    968K     .CAF [Updated 2009-05-25], [Updated 2009-09-30] Best Choice for iPhone 3GS
  • kAudioFormatMACE3                   = ‘MAC3′,    NG            .CAF
  • kAudioFormatMACE6                   = ‘MAC6′,    NG            .CAF
  • kAudioFormatULaw                    = ‘ulaw’,    OK    5.1M     .CAF
  • kAudioFormatALaw                    = ‘alaw’,    OK    5.1M     .CAF
  • kAudioFormatQDesign                 = ‘QDMC’,    NG            .CAF
  • kAudioFormatQDesign2                = ‘QDM2′,    NG            .CAF
  • kAudioFormatQUALCOMM                = ‘Qclp’,    NG            .CAF
  • kAudioFormatMPEGLayer1              = ‘.mp1′,    NG            .CAF
  • kAudioFormatMPEGLayer2              = ‘.mp2′,    NG            .CAF
  • kAudioFormatMPEGLayer3              = ‘.mp3′,    NG            .CAF
  • kAudioFormatAppleLossless           = ‘alac’        OK    4M        .CAF
  • kAudioFormatMPEG4AAC_LD             = ‘aacl’,    NG            .CAF
  • kAudioFormatAMR                     = ‘samr’,    NG            .CAF
  • kAudioFormatiLBC                    = ‘ilbc’,    NG    Wierd    .CAF

The list here has omitted all the other data format that are not supported by CAF file extension. You can use the console application afconvert to verify each supported file format and data format via typing this:

afconvert -h

All the tests were recorded in 60 seconds, with sample rate@44100, 2 channels, 96kbps. The RecordSetting Dictionary object is used as below:

recordSetting = [[NSMutableDictionary alloc] init];

//General Audio Format Settings (Necessary for all audio format.)
[recordSetting setValue:[NSNumber numberWithInt: kAudioFormatMPEG4AACkAudioFormatAppleIMA4] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];

//Linear PCM Format Settings (only necessary when you want to record Liner PCM format)
[recordSetting setValue:[NSNumber numberWithInt: 32] forKey:AVLinearPCMBitDepthKey];
[recordSetting setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
[recordSetting setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];

//Encoder Settings (Only necessary if you want to change it.)
[recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityMin] forKey:AVEncoderAudioQualityKey];
[recordSetting setValue:[NSNumber numberWithInt:96] forKey:AVEncoderBitRateKey];
[recordSetting setValue:[NSNumber numberWithInt:16] forKey:AVEncoderBitDepthHintKey];

//Sample Rate Conversion Settings (Only necessary when you want to change the sample rate to a value different to the hardware sample rate, AVAudioQualityHigh means no conversion, usually, 44.1KHz)
[recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityHigh] forKey:AVSampleRateConverterAudioQualityKey];

[Updated 2009-09-30], The record settings listed above was for example only, if you want to record IMA4 or other compressed audio format, you are no need to put the Liner PCM part. Other parts are commented for their purpose.

You can see, the MPEG4AAC has the minimum file size and same quality when compare to other file formats. About the AAC format, please refer to [Wikipedia – AAC”]

Apple, you could just give us a best practice guide! So I won’t need to test it one by one myself. OK, I know, you are working out of people, hire me, I would love to do these works.

iOS Wireless Distro

1、在Organizer里Share

2、URL和Application Name需相同

3、导出ipa和plist文件

4、创建链接文件,给Safari点击即可。

<a href="http://www.xxx.com/xxx.mobileprovision">
1. Install Provisioning File</a>

<a href="itms-services://?action=download-manifest&amp;url=http://www.xx.com/xxx.plist">
2. Install Application</a>

VirtualBox访问Windows共享目录

1、在Windows设置共享目录,在VirtualBox设置共享目录。

2、在Mac:
Go>Connect to Server
smb://10.0.2.2

3、在Linux:
sudo mount -t vboxsf Shared /mnt/shared
(假设共享目录名为shared,挂在/mnt/shared)