codegen on iOS problem

466 views
Skip to first unread message

Kittipun Khantitrirat

unread,
Dec 5, 2013, 3:50:24 AM12/5/13
to echo...@googlegroups.com
I've successfully complied codegen on iOS7. But the problem is when I tried to use run codegen to convert PCM to code, the output will be blank or there will be some random char.

For example:

2013-12-05 15:43:57.230 echoprint[978:60b] Doing codegen on 105679 samples...
2013-12-05 15:44:00.259 echoprint[978:60b] Done with codegen
2013-12-05 15:44:00.262 echoprint[978:60b] Done òJº9
2013-12-05 15:44:01.421 echoprint[978:60b] {
    response =     {
        songs =         (
                        {
                error = "need codes in query for fingerprint matching";
            }
        );
        status =         {
            code = 0;
            message = Success;
            version = "4.2";
        };
    };
}

Those are the console output from iOS example. Can someone help me what i'm doing anything wrong?

Kittipun Khantitrirat

unread,
Dec 5, 2013, 1:54:16 PM12/5/13
to echo...@googlegroups.com
After some investigation going on. I've found a problem in Codegen_wrapper.cpp of this particular code:

string s = c->getCodeString();
return s.c_str();

the s.c_str() method is using to return the code in const char variable. When I used a break point to check the value of the variable. It worked okay but it always will return empty string to outer function.

I've checked on other people who having const char problem in iOS 7 and there's a topic about it. http://stackoverflow.com/questions/18901776/ios-6-and-7-doesnt-return-same-results

The cause is that const char is null-terminated string. So when it's return to outer function. it will be destroyed by ARC. (I'm not really sure about it though. Still working on iOS skill) The workaround is still working on. I have a little knowledge in C++. So, if anybody can help me with this one I will be really appreciate. :D

Andrew Nesbit

unread,
Dec 5, 2013, 2:07:40 PM12/5/13
to echo...@googlegroups.com
Thank you for the bug report, Kittipun. As you've noticed, the codegen hasn't yet been updated for iOS 7, but that's one of the many things we're working on. If you have a patch, either for this particular issue or for the iOS 7 app more generally, please feel free to contribute it. Otherwise, we'll look into this in due course anyway.


--
You received this message because you are subscribed to the Google Groups "echoprint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to echoprint+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Kittipun

unread,
Dec 5, 2013, 2:11:58 PM12/5/13
to echo...@googlegroups.com
Thanks for fast response! I’m still looking for a way around but found no solution. Can you please take a look at it?
You received this message because you are subscribed to a topic in the Google Groups "echoprint" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/echoprint/Zi_ip49Xgds/unsubscribe.
To unsubscribe from this group and all its topics, send an email to echoprint+...@googlegroups.com.

Andrew Nesbit

unread,
Dec 5, 2013, 3:06:37 PM12/5/13
to echo...@googlegroups.com
On Thu, Dec 5, 2013 at 7:11 PM, Kittipun <boo...@gmail.com> wrote:
Thanks for fast response! I’m still looking for a way around but found no solution. Can you please take a look at it?

I was looking at this stuff last week because I do realise it needs an update, but getting it fully updated needs a bit more work. I can't do it right this second, but if anybody else has any ideas, go for it.

Kittipun Khantitrirat

unread,
Dec 22, 2013, 4:57:25 PM12/22/13
to echo...@googlegroups.com
I'm still finding the way to solve the bug. Still haven't got any. :(

If somebody going to take a look at this I will be really appreciated. I'm working on my student project and can't go anywhere without solving this bug. :(

Darren Cullen

unread,
Jan 27, 2014, 7:11:38 PM1/27/14
to echo...@googlegroups.com
Hi Kittipun,

It might be too late for you given that you were working on a college project, but if not, this link might be of use:


I haven't tested it, but it claims to be an iOS7 implementation of echoprint.

Good luck.
Darren

Kittipun Khantitrirat

unread,
Jan 27, 2014, 9:02:27 PM1/27/14
to echo...@googlegroups.com
Hi Darren,

Thanks for the link! I will try that very soon. Actually, I've solved the problem by changing where the codegen working.

Instead of running codegen on iOS device, I send the recorded audio file to a modified api.py and running codegen from there.

But the problem is that the size of PCM audio is so large. So, I have to compressed the file with AAC. Not really sure how much it will affected the performance though.

Todd Tieger

unread,
Feb 13, 2014, 7:47:44 PM2/13/14
to echo...@googlegroups.com
I get the identical response - even using the supposed updated iOS7-compatible codebase in https://github.com/rexstjohn/echoprint-ios-sample

I play songs directly on my machine from iTunes that I have cross-checked with echo print's listing of encoded songs, but I always get the same response.  I have tried running longer than 30 seconds, but this does not solve the problem.

I have also tried embedding a test file as a static PCM test module.  When this file is sent to echoprint, it returns with the proper ID.

Clearly, the codegen C++ wrapper code does not work for me.

Has ANYONE gotten this to work on iOS7/iPhone 5?
Todd Tieger

Desmond Hume

unread,
Feb 22, 2014, 5:56:26 PM2/22/14
to echo...@googlegroups.com
Having the exact same problem. Also with rexstjohn/echoprint-ios-sample
Anyone know the solution?

Scott Andrew

unread,
Feb 22, 2014, 8:00:54 PM2/22/14
to echo...@googlegroups.com
I was able to fix this by making codegen an objective file. I then created a encode function in codegen and had it return an NSString.. 

NSString* Codegen::encode(const float* pcm, unsigned int numSamples, int start_offset) {

    if (Params::AudioStreamInput::MaxSamples < (uint)numSamples)

        throw std::runtime_error("File was too big\n");

    

    Whitening *pWhitening = new Whitening(pcm, numSamples);

    pWhitening->Compute();

    

    AudioBufferInput *pAudio = new AudioBufferInput();

    pAudio->SetBuffer(pWhitening->getWhitenedSamples(), pWhitening->getNumSamples());

    

    SubbandAnalysis *pSubbandAnalysis = new SubbandAnalysis(pAudio);

    pSubbandAnalysis->Compute();

    

    Fingerprint *pFingerprint = new Fingerprint(pSubbandAnalysis, start_offset);

    pFingerprint->Compute();

    

    _CodeString = createCodeString(pFingerprint->getCodes());

    _NumCodes = pFingerprint->getCodes().size();

    

    NSString* string = [[NSString alloc] initWithUTF8String:_CodeString.c_str()];

    

    return string;

}


I don't quite have an answer as to why the class's ivars are being trashed.

Rex St. John

unread,
Feb 23, 2014, 1:33:20 AM2/23/14
to echo...@googlegroups.com
Ah, people are using my iOS 7 fork. I was working on that because I needed it for a client project which got canceled so I stopped messing with it. If you have a solution please add it and do a pull request and I will upgrade it so more people aren't being driven nuts by it. Otherwise maybe I should take it down.

Desmond Hume

unread,
Feb 23, 2014, 6:52:54 AM2/23/14
to echo...@googlegroups.com
Thanks for your solution.

Any chance you can provide a bit more information how to accomplish this?

Scott Andrew

unread,
Feb 23, 2014, 3:36:08 PM2/23/14
to echo...@googlegroups.com
There was an interesting post about a new library release that is available. I am going to try that mine is a bit of a stop gap.


On Thursday, December 5, 2013 12:50:24 AM UTC-8, Kittipun Khantitrirat wrote:

Victor Polevoy

unread,
Mar 5, 2014, 11:05:16 AM3/5/14
to echo...@googlegroups.com
For people who still need this echoprint-ios-example to be worked I've forked Rex St. John's one into https://github.com/vityafx/echoprint-ios-sample. I've modified the project to run succesffully on iOS7. Also removed the codegen problem.
I've already sent a pull request to Rex St. John's repository.

понедельник, 24 февраля 2014 г., 0:36:08 UTC+4 пользователь Scott Andrew написал:

Rex St. John

unread,
Mar 9, 2014, 12:19:57 AM3/9/14
to echo...@googlegroups.com
Hey all, a cool Russia dude checked in a potential fix last week and I have merged it. Please take a look at the repo now and give me any feedback.

Rex St. John

unread,
Mar 11, 2014, 1:20:02 AM3/11/14
to echo...@googlegroups.com
Update: I merged Victor's fork and then made a number of adjustments to the project to get it to compile. I was able to successfully test acoustic fingerprinting from music on the device and from the microphone: https://github.com/rexstjohn/echoprint-ios-sample

Rex St. John

unread,
Mar 11, 2014, 1:20:21 AM3/11/14
to echo...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages