-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Codec 2 700C encode #1
Comments
any progress with that? I've tried implementing encode and decode using Codec2 class, without using built-in Codec2Decoder, and no luck... more info in question on SO @mikedawson maybe there is a chance for some simple sample or Codec2Encoder class accompanying existing decoder? |
Sorry it has been a while since I have worked on this as you can see and I haven't been able to maintain this one actively. I think this might be related to the header. I vaguely remember this issue when testing different sample sizes but I think it got lost at the time. I remember something like this : everything was fine until the frame size is changed (e.g. by a change bitrate). In the samples that were included here (e.g. in the assets), the header and the frame size were the same (or multiples), so the result was missing a frame or two, which was not noticeable. When the header size and frame size were not multiples of each other, then the frame data is essentially out of alignment, and the result is then garbage output. Unfortunately fixing it probably requires digging into the implementation, connection to the codec2 library, and some understanding of codec2 itself. I can provide hints and advise from what I can remember, and I can check / merge any pull request to fix it, but unfortunately at the moment I don't have the time to resolve it directly. It's something that I might get to work on again in the next months, but not in the short term. My apologies for the issue and that I can't directly resolve it. |
It seems like this library was used here in codec2_talkie here: https://github.com/sh123/codec2_talkie/tree/master/libcodec2-android Maybe the change list there (or the maintainers there) resolved this issue. I think it makes sense to have a libcodec2 library that its own module not tied to any particular app. |
thanks for suggestions and reply I don't have any file in my scenario, so I'm not sure that "header case" is for me... I'm recording and playing using Android classes: I've tried to decode my encoded data with your decoder, VERY no luck, garbage... it plays sample file fine, so I'm suspecting that sooner my encoding side is somehow "wrong" than decoding BUT: as "mine" encoding and "mine" decoding are cooperating partially (voice is hardly "understandable", far from sample files) then I'm suspecting both my sides implemented in a wrong way, maybe with same/shared mistake... Am I loosing some data when transforming char/byte/short array? or maybe I'm messing/not setting little/big endian...? literally no clue.. the crucial question to you is: have ever ENcoded raw audio/pcm to c2 format using your implementation? as you have decoder and no encoder... maybe you just needed one direction only and never tested second one? I've tried to build your project, but it needs Linux env... thats very good catch that thanks again for response and insights, looking forward for answer if you can confirm that encoding is/was/should working fine (and maybe still is in some soft still in use) |
I think the answer is in the demo code:
If the header is not skipped or read before using the Codec, then it reading frames will be out of alignment and the output will be garbled. Also you must make sure that the mode passed to the decoder matches how the file was encoded. I think I encoded the files using the compiled version of c2 on the command line. My use case for this (education videos in limited bandwidth environments) at the time only required playback on Android. |
Your
Rest of code is exacly same, my data is a mess... should I remove also header from my raw output? its fixed I've planned to use 700C, but for compatibility purposes (with your sample code and audio files) I'm testing with hardcoded |
I think the reason char is used in these cases is because it provides a 16bit unsigned value (that seemed to be the norm for audio stuff on Android). It shouldn't be considered as an actual char or something that can be turned into a string. My recommendation would be as follows:
|
I've adjusted my player to your files, so that side is fine. Now both decoders work properly with files and I'm trying to adjust encoder I've noticed that every encoded char in buffer is <=255, thus it can be converted to byte easily. so 2-byte-char becomes 1-byte-byte. after this change, instead of and the real question is: what happens on JNI side in due to comment edit: looks like |
So does that mean the decoder is working with any file that you encode using c2enc on the command line? That's good to hear. On the encode: I think this comes from the library that I forked it from. I didn't work on the encoding side. I think Android generally uses 16Khz, so the normal approach was to down sample by dropping odd samples. You could try backporting the change from codec2_talkie and see if that resolves the issue. It seemed to me like the native build approach in codec2_talkie was not using the recommended approach. I tried to structure the Gradle, C files etc as per the recommended structure. I found that made the cross compilation (e.g. for arm 64) relatively painless. |
I can confirm that exchaning
to
will fix an issue. I won't contribute, as I don't have linux for building and testing your project, tried VMs, but had a problems even running Ubuntu, too much work... It just my side project for fun, I just didn't believed that we can pack up speech into 700bits per sec, even 3200 is awesome result. And yes we can :) How do I know that this is a real fix? because I'm producing 8khz sample array (yes, possible on Android), then adding it to new short array with additional 0x00 bytes on even positions. These bytes will be dropped by you on JNI side
|
Hi,
Im trying to encode a stream of input data that i get from AudioRecord and encode it to 700C.
Im getting 320 Bytes of speach frames into 4 bytes.
However the output isn't similar to the output that https://github.com/drowe67/codec2 gets.
Does anyone else has that problem / can help me?
The text was updated successfully, but these errors were encountered: