install harmtrace in linux

install haskell-platform
update cabal
cabal install HarmTrace

it will warn u no gsl
install gsl then

sudo apt-get install libgsl0-dev liblapack-dev

then
cabal install HarmTrace

finish

~/.cabal/bin/harmtrace

harmtrace recognise –file=/Users/roychung/project/harmtrace/let_it_be.mp3 –mode=group –grammar=pop -o=/Users/roychung/project/harmtrace/output –log-dir=/Users/roychung/project/harmtrace/log –csv-dir=/Users/roychung/project/harmtrace/csv –sa-path=/Users/roychung/project/harmtrace/sonic-annotator –vamp-dir=/Users/roychung/project/harmtrace/vamp

in /Users/roychung/project/harmtrace/vamp need transform file
which is generate by sonic annotator

http://code.soundsoftware.ac.uk/projects/sonic-annotator/wiki

then it will say no sox

http://sox.sourceforge.net/

then sox want lame and mad (from readme)
install them

transform file is sth like :
$ sonic-annotator -s vamp:vamp-example-plugins:fixedtempo:tempo
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix vamp: <http://purl.org/ontology/vamp/> .
@prefix : <#> .

:transform a vamp:Transform ;
vamp:plugin <http://vamp-plugins.org/rdf/plugins/vamp-example-plugins#fixedtempo> ;
vamp:step_size “64”^^xsd:int ;

vamp:block_size “256”^^xsd:int ;
vamp:parameter_binding [
vamp:parameter [ vamp:identifier “maxbpm” ] ;
vamp:value “190”^^xsd:float ;
] ;
vamp:parameter_binding [
vamp:parameter [ vamp:identifier “maxdflen” ] ;
vamp:value “10”^^xsd:float ;
] ;
vamp:parameter_binding [
vamp:parameter [ vamp:identifier “minbpm” ] ;
vamp:value “50”^^xsd:float ;
] ;
vamp:output <http://vamp-plugins.org/rdf/plugins/vamp-example-plugins#fixedtempo_output_tempo> .
$

hint:
beat-tracker transform need change to 256 …
it has error about it, or u cannot generate the beat-tracker.txt

something about harmtrace on mac and ubuntu

i m going to install your harmtrace in my mac to make some chord file. but unluckily, i always got buildFail when linking to a package call hmatrix-gsl-stats-0.2

<... some loading package message above .. >
Loading package vector-0.10.0.1 … linking … done.

Loading package hmatrix-0.15.2.1 … linking … done.

Loading package hmatrix-gsl-stats-0.2 … linking … ghc:

lookupSymbol failed in relocateSection (relocate external)

/Users/roychung/Library/Haskell/ghc-7.6.3/lib/hmatrix-gsl-stats-0.2/lib/HShmatrix-gsl-stats-0.2.o: unknown symbol `_mean’

ghc: unable to load package `hmatrix-gsl-stats-0.2′

Failed to install HarmTrace-2.2.0

Updating documentation index /Users/roychung/Library/Haskell/doc/index.html

cabal: Error: some packages failed to install:

HarmTrace-2.2.0 failed during the building phase. The exception was:

ExitFailure 1

do u have idea to solve ?

i m in OSX 10.9

Roy Chung

Thx so much for u reading this email (though u dun solve my problem)

========================================================================================================================

I just reinstall the whole things. and turn off “shared: False” in cabal config when face this linkage problem. This will turn off the linkage dynamic lib of apple , i think the problem is occur by here. And harmtrace can be succeed install.

And i try to install virtualbox and install an ubuntu image. It just install successfully and smoothly. (so i think linux is better … )

[ios] audio conversion using AVAssetExportSession / AVAssetWriter from AVFoundation

Target : ipod library -> aiff / wav / caf (which eat by libsndfile (already ported to ios))

first, i think AVAssetExportSession can solve my problem due to this link:

http://tuchangwei.github.io/blog/2013/06/04/how-to-export-mp3-from-ipod-library/

but it is for converted-to-mp3 only (or converted-to-m4a)

(Trick :

Some points you need notice:
when you init AVAssetExportSession object, the “presetName” argument must be “AVAssetExportPresetPassthrough”.
The “outputFileType” may be “com.apple.quicktime-movie”.

And rename to mp3)

why i know it is for mov or m4a

if u write :
NSLog(@”export.supportedFileTypes : %@”,export.supportedFileTypes);

u will get:
exporter.supportedFileTypes : (
“com.apple.quicktime-movie”,
“com.apple.m4a-audio”,
“public.mpeg-4”,
“com.apple.m4v-video”,
“public.3gpp”,
“org.3gpp.adaptive-multi-rate-audio”,
“com.microsoft.waveform-audio”,
“public.aiff-audio”,
“public.aifc-audio”,
“com.apple.coreaudio-format”
)

but it is only telling u these type exporter can convert
in api:
Discussion
Not all presets are compatible with all assets.

So after i run
NSLog(@”%@”, [AVAssetExportSession exportPresetsCompatibleWithAsset:songAsset]);
2014-05-27 18:29:35.792 Jtab[1723:60b] (
AVAssetExportPresetAppleM4A,
AVAssetExportPreset960x540,
AVAssetExportPresetLowQuality,
AVAssetExportPresetMediumQuality,
AVAssetExportPreset640x480,
AVAssetExportPresetHighestQuality,
AVAssetExportPreset1280x720
)

only m4a is available (and mp3 using mov one)
whatever your ipod library song is mp3, m4a, wav (i tried)
so it is fail

And note that using AVAssetExportSession, the output extension is concerned, if type != extension will error

So i go to other solution AVAssetWriter:

wav example:
http://objective-audio.jp/2010/09/avassetreaderavassetwriter.html

wav example:
http://iphonedevsdk.com/forum/iphone-sdk-development/62807-export-audio-as-m4a-alac.html

caf example:
http://swordinhand.iteye.com/blog/1942043

同場加映:

Easy AAC compressed audio conversion on iOS
http://atastypixel.com/blog/easy-aac-compressed-audio-conversion-on-ios/
using https://github.com/michaeltyson/TPAACAudioConverter

But i think use AVAssetExportSession to m4a can solve the problem…,so TPAACAudioConverter is useless now

strong vs retain and weak vs assign and blah blah blah

After reading so many articles, SO posts and demo apps to check variable property attributes, I decided to put all the attributes information together:

atomic //default
nonatomic
strong=retain //default
weak
retain
assign //default
unsafe_unretained
copy
readonly
readwrite //default
Below is the detailed article link where you can find above mentioned all attributes, that will definitely help you. Many thanks to all the people who give best answers here!!

Variable property attributes or Modifiers in iOS

1.strong (iOS4 = retain )

it says “keep this in the heap until I don’t point to it anymore”
in other words ” I’am the owner, you cannot dealloc this before aim fine with that same as retain”
You use strong only if you need to retain the object.
By default all instance variables and local variables are strong pointers.
We generally use strong for UIViewControllers (UI item’s parents)
strong is used with ARC and it basically helps you , by not having to worry about the retain count of an object. ARC automatically releases it for you when you are done with it.Using the keyword strong means that you own the object.
Example:

@property (strong, nonatomic) ViewController *viewController;

@synthesize viewController;
2.weak –

it says “keep this as long as someone else points to it strongly”
the same thing as assign, no retain or release
A “weak” reference is a reference that you do not retain.
We generally use weak for IBOutlets (UIViewController’s Childs).This works because the child object only needs to exist as long as the parent object does.
a weak reference is a reference that does not protect the referenced object from collection by a garbage collector.
Weak is essentially assign, a unretained property. Except the when the object is deallocated the weak pointer is automatically set to nil
Example :

@property (weak, nonatomic) IBOutlet UIButton *myButton;

@synthesize myButton;
Strong & Weak Explanation:

Imagine our object is a dog, and that the dog wants to run away (be deallocated). Strong pointers are like a leash on the dog. As long as you have the leash attached to the dog, the dog will not run away. If five people attach their leash to one dog, (five strong pointers to one object), then the dog will not run away until all five leashes are detached. Weak pointers, on the other hand, are like little kids pointing at the dog and saying “Look! A dog!” As long as the dog is still on the leash, the little kids can still see the dog, and they’ll still point to it. As soon as all the leashes are detached, though, the dog runs away no matter how many little kids are pointing to it. As soon as the last strong pointer (leash) no longer points to an object, the object will be deallocated, and all weak pointers will be zeroed out. When we use weak? The only time you would want to use weak, is if you wanted to avoid retain cycles (e.g. the parent retains the child and the child retains the parent so neither is ever released).

3.retain = strong

it is retained, old value is released and it is assigned retain specifies the new value should be sent
retain on assignment and the old value sent -release
retain is the same as strong.
apple says if you write retain it will auto converted/work like strong only.
methods like “alloc” include an implicit “retain”
Example:

@property (nonatomic, retain) NSString *name;

@synthesize name;
4.assign

assign is the default and simply performs a variable assignment
assign is a property attribute that tells the compiler how to synthesize the property’s setter implementation
I would use assign for C primitive properties and weak for weak references to Objective-C objects.
Example:

@property (nonatomic, assign) NSString *address;

@synthesize address;
share|improve this answer
edited Nov 14 ’13 at 8:25

http://stackoverflow.com/questions/8927727/objective-c-arc-strong-vs-retain-and-weak-vs-assign

cannot get position, or cell reuse animation cannot control

if u r doing AVAudioPlayer, and u grep currentTime, if u wanna has a more accurate time, it cannot do it … since it is quite discrete (for compress song like mp3) … so

CACurrentMediaTime() may help u

beginTime = CACurrentMediaTime()

… some animation …

animateTime = CACurrentMediaTime() – beginTime

so i have some value can calculate the view if the animation wanna pause in the middle

(too complicated animation recommend use CAKeyFrameAnimation)

[ios] declare const

1. private

myfile.m
NSString *const SelectionSort = @”SelectionSort”;

2. public

myfile.h
extern NSString *const SelectionSort;
and in myfile.m define them

myfile.m
NSString *const SelectionSort = @”SelectionSort”;

It works, but only if you need a non global constant. Static constant is not visible outside the file. Otherwise use the 1st option.

http://stackoverflow.com/questions/6188672/where-do-you-declare-constant-in-objective-c

============================================

The #define is a pre-processor macro. That means that it basically goes through your code and replace your macro with what you’ve defined.

If you use a const, it’s going to be a pointer to the string in memory. It’s way more efficient than having the same string being allocated wherever/whenever it is used.

To do that, you’ll need both .h and .m files. Your .h file will look something like:

extern NSString * const YOUR_STRING;
And your .m file:

NSString * const YOUR_STRING = @”your string”;

no need Class.THIS_IS_A_CONST , just THIS_IS_A_CONST then ok

===============================================

把NSString宣告為常數
錯誤的宣告方式
會出現warning:(Sending ‘const NSString *__strong’ to parameter of type ‘NSString *’ discards qualifiers)
.h
extern NSString * SelectionSort;
.m
const NSString *InsertionSort = @”SelectionSort”;

正確的宣告方式
.h
extern NSString *const SelectionSort;
.m
NSString *const SelectionSort = @”SelectionSort”;

http://mywayonobjectivec.blogspot.hk/2014/05/nsstring.html

UICollectionView 的心路歷程

project 是寫一個 guitar chord + music player
data 只有 那些 chord, 我的 project 就是要 用 cell 一格格的跟住音樂 著燈

1. using UICollectionView
problem 1: offset
因為我用了 endTime – startTime, 原來會累積 一些 error ,導致後面不準

problem 2: UICollectionView reloaditemsAtIndexPath 有 animation 在閃
求其 set 了 就繼續做
[UIView setAnimationsEnabled:NO];

http://stackoverflow.com/questions/14094684/avoid-animation-of-uicollectionview-after-reloaditemsatindexpaths

到第一個 deadline : 發現這兩問題

首先要解決閃的問題,因為 setAnimationsEnabled:NO 會令到 needle (音樂器的秒數指標)

solution 1 : 用了 PSTCollectionView ,改 src code, 熄了那 .3 的 animation
但用舊野可能有後遺症
所以轉了第二個 function

用 reloadData , 其實是整幅 cells reload
壞處是不能有 animation 在其中,不斷 call 的話,scroll 也不能
visibleCells 也有不準的情況 (其實放在 reload 前 就會o岩了)

offset 問題,本想用 ticker 可處理
每 0.01 秒去 發 notification 和 cells 對話
cells 轉自己的 isCurrentChord = YES 同埋
call delegate (viewController) 話邊粒係 current
本應很好,但 0.01 秒去 call 一個 reload function
call reloadData 還好,call reloaditemsAtIndexPath 簡直炒晒
因為 refresh 得太密, scroll 要自己設計,click 亦不能,此路不通

solution 3 : 返回基本步,用 UICollectionView ,仍覺得閃可以解決,使用了
[UIView animateWithDuration:0 animations:^{
[collectionView performBatchUpdates:^{
[collectionView reloadItemsAtIndexPaths:indexPaths];
} completion:nil];
}];

needle 仍舊不能動

好友提議下,將 endTime – startTime 改成 currentCell.startTime – musicPlayer.currentTime 做 timer interval
currentIndex++ after one timer trigger

offset 問題解決了,誤差不會再 stack 上去, 就算有誤差,都係本身一個 cell 的極少誤差

reloadItemsAtIndexPaths 不能用,唯有用 relaodData
注意 reloadData 係 async 的
亦 rmb use layoutIfNeeded 去 trigger update
但因為無用 ticker, 小心處理動畫問題,用起上來蠻方便的