600D Audio TEST release - 2.3 based

Started by scrax, August 13, 2012, 10:28:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

1%

You could put it in bit rate menu but running out of space in there. It would work in fps override without much changes if it works for regular recording. People were wanting to do it in another thread and complaining about it.  This solves both issues and frees up the encoder for video.

It also takes care of that 2 second delay for override and probably takes out more overhead as you don't have to override as much. People can chose either mode with minimal changes besides the functions to start wav when movie starts and change the name, etc. Also audio easier to turn on/off. Right now you have to leave it on all the time or turn it off and go through many menus to bring it back.

Also this possibly ports over to other cameras since the voice recorder does too. Just have to see if delay is from current functions re-overriding audio or from something else or if its present on external.

Debug.c is full and I can maybe get rid of 1 gop option that is actually calculated.

http://imgur.com/a/NHM6R


miyake

@1%
I see your work. And some people want to record sound FPS override. So we need to think about good UI for sound recording.

If we turn on "wave recording togeter"
-Automatically disable canon audio, if it enabled
-get current recording file name and then change extension to WAV for recording sound file.
-start wav recording when we push MVR record button.(Actually start recording after override setting will finish , I think.)

BTW, FPS override person is what is talking? I think FPS override need a lot of time for recording. Are they want to record all of time for recording FPS overriding video recording????
I think they only need few second for post.

1%

You can do a few seconds or whole time, wav is spearate so theoretically it won't be affected. Rate wouldn't have to match FPS rate.

QuoteIf we turn on "wave recording togeter"
-Automatically disable canon audio, if it enabled
-get current recording file name and then change extension to WAV for recording sound file.
-start wav recording when we push MVR record button.(Actually start recording after override setting will finish , I think.)

Pretty much this. Also then you can keep audio off and turn on wav recording to set audio on/off quickly.  Can be 1 setting. Would only have to set up audio before record and override whatever wav recorder changes. All other settings would work the same I think, they seem to now.

scrax

Voice tag is great, just tried right now from source.
If with that we can record audio with canon audio off and video, I think that maybe we can keep canon off by default and use only ML audio with override only for play mode.

Tested audio off and video recording but I have a delay effect on the recorded audio.
Like:
Testing audio recording

Tete-stst-inin-g g g...

not all audio gets recorded.
with CBR set to 0,1 it goes better but not perfect, sometimes it still skips like looping some part of audio data.
with low FPS it is the best so far, but really ok only when recording audio alone.
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

1%

Yep, that is the echo. For me it only comes up sometimes. Probably related to card speed. When it echoes is when audio starts dropping out. Fine tuning the buffer for wav recorder might help.

miyake

hmm,
My guess.
- h264 stream and voice data writing together.
- voice data writing gets blocking when finish previous writing.
-->On chip audio raw data is discard, and we can read next buffer.

I think canon audio data function using ring buffer, so I think we had it problem.
Then I think we also use memory buffer to read it.

BTW, I'm not testing voice tag functions yet  ;D


1%

Can try in gop 1 where it constantly writes out the buffer and see if echo gets worse.

miyake

What you mean "gop 1"?
GOP only 1frame? Is this writing each GOP? Then H264 stream will write more small chunk on each frames?
right?

1%

Gop = group of pictures. Made of I frames and P frames on 600D. Gop1 = all I frames. Gop 3 is 1 I frame and 2 p frames, etc. I frame written out pretty much immediately, P frame stored in buffer. I see by sd card light.

miyake

My English question was poor. but My understanding is  correct. I know GOP and it's architecture.
BTW, All user need to ALL I frames when they want to record WAV.
Adding Buffer function is more better I think. Because it's don't need to care about WAV with GOP.
Anyway, need more testing for it. And I have no repo for merged your codes. Can you try it?


BTW, it's a little difficult to collaborate code with another cameras.
I think WAV related functions need to implement another camera first. Then we will add 600D optimization after finishing them.
Now I can write all of your request, but I think it's not good for another cameras.
It's not only 600D functions (It's a global function), I think it's not good to write 600Daudio repos.
So I think we will talk more with Alex.
(Need to create new repo which is  WAV record with MVR-no-sound recording for creating patches.)

1%

I tried it, it gets a little worse but not as bad as I expected. I was thinking it would be all distorted 90% of the time but its more like only at certain times. Seems to drop out more when there is a buffer warning and meters start to lag.

Maybe try it in shoot malloc next?

Tried but got machine gun noise instead of audio this time, it used to work for non continuous wav.

miyake

Thanks for your testing.

Need to add simple buffer function for testing. And recording time is most sensibly for usage of CPU/mem.
Full ringbuffer implementation need a lot of CPUs.

hmm, how to share my codes. I don't wanna add testing code to my 600D audio repo.
made a patch for it

MSG added
hmm, how to asynchronous read/write impliment? need to more research on audio buffer...

1%

Make a new repo or you can just add it to mine. I have it set up for audio6.c and audio.c is from regular ml.

miyake

This is wav writting buffering patch.

diff -r ae36c8b5889b src/beep.c
--- a/src/beep.c        Sun Sep 02 02:50:47 2012 +0900
+++ b/src/beep.c        Mon Sep 03 19:53:43 2012 +0900
@@ -172,7 +172,10 @@
static FILE* file = INVALID_PTR;
#define WAV_BUF_SIZE 8192
static int16_t* wav_buf[2] = {0,0};
+#define WBUF_SIZE 16
+static int16_t* write_buf[WBUF_SIZE];
static int wav_ibuf = 0;
+static int write_ibuf = 0;

static void asif_continue_cbr()
{
@@ -327,7 +330,18 @@
     if (file == INVALID_PTR) return;

     void* buf = wav_buf[wav_ibuf];
-    FIO_WriteFile(file, UNCACHEABLE(buf), WAV_BUF_SIZE);
+    memcpy(write_buf[write_ibuf],buf,WAV_BUF_SIZE);
+    if (write_ibuf==(WBUF_SIZE-1)){
+        int i;
+        for(i=0;i<WBUF_SIZE;i++){
+            void* writebuf = write_buf[i];
+            FIO_WriteFile( file, UNCACHEABLE(writebuf), WAV_BUF_SIZE );
+        }
+        write_ibuf=0;
+    }else{
+        wav_ibuf = !wav_ibuf;
+        write_ibuf++;
+    }

     if (audio_recording == 2)
     {
@@ -338,7 +352,6 @@
         return;
     }
     SetNextASIFADCBuffer(buf, WAV_BUF_SIZE);
-    wav_ibuf = !wav_ibuf;
}

void WAV_Record(char* filename, int show_progress)
@@ -358,7 +371,7 @@
     SetSamplingRate(48000, 1);
     MEM(0xC092011C) = 4; // SetASIFADCModeSingleINT16

-    wav_ibuf = 0;
+    wav_ibuf=0;
     StartASIFDMAADC(buf1, WAV_BUF_SIZE, buf2, WAV_BUF_SIZE, asif_rec_continue_cbr, 0);
     while (audio_recording)
     {
@@ -846,6 +859,10 @@
{
     wav_buf[0] = alloc_dma_memory(WAV_BUF_SIZE);
     wav_buf[1] = alloc_dma_memory(WAV_BUF_SIZE);
+    int i=0;
+    for(i=0;i<WBUF_SIZE;i++){
+        write_buf[i] = alloc_dma_memory(WAV_BUF_SIZE);
+    }

     beep_sem = create_named_semaphore( "beep_sem", 0 );
     menu_add( "Audio", beep_menus, COUNT(beep_menus) );



But result is not so good.
sound is some time lost and memcpy overhead increase CPU& mem.
You can change buffer size (how many buffers aggreate to write) by WBUF_SIZE ....


MSG added
This code is just only provide a write aggregation.
Not providing async write/read.

a1ex

If you want to record a separate WAV file in parallel with movie recording, this should do the trick:

http://bitbucket.org/hudson/magic-lantern/changeset/2ecf53a6b327b7ae05e3f783ad6f3b73377f1ce2

I didn't play much with it, just recorded a few videos on 5D3, played back the audio, and worked just fine. I didn't check the sync between audio and video; probably there's some constant delay that has to be applied.

miyake: what does your patch do? WAV recording works fine in 5D2/5D3/550D. First implementations had some sound glitches because I was writing the wrong buffer to file (i.e. the same that was being updated), but now it sounds good to me.

miyake

I want to record CBR 3.0 with WAV sound.
Current code is sometime lost audio buffer when finish writting to file.
I guess, WAV write is waiting(blocking) to finish MVR write. Then , audio buffer will renewal to newest raw data.

Then I make a patch for testing. If we aggregate writing part, we can success writing together or not.

miyake

@1% and alex

Maybe this patch solved CBR3.0 and WAV record issue.
Previously I only to test on my KINGMAX SD card.

Now I have 2 SD cards.
- KINGMAX 32GB SDHC
-SANDISK EXTREME PRO 64GB SDXC

my code provide to solve CBR 3.0 + WAV record using SANDISK. But I can't confirm normal writting method using KINGMAX.
So I don't say correct thing.
Anyway, writing speed is depend the reason of  lost audio segment.

We need to add asynchronous read/write for storing WAV sound.

a1ex

Got it. In this case, you need a big buffer (20MB maybe, possible with shoot_malloc) in which you can write small audio buffers, because a lot FIO_WriteFile calls are very slow.

See here for some benchmarks with different write buffer sizes: http://groups.google.com/group/ml-devel/browse_thread/thread/77fc7e58dd86a7ed

1%

I tried shoot_malloc and it made machine gun sounds instead of audio. Only problem so far with that function is that FPS override HAS to disable audio... if you start with audio off it says sound disabled and won't record.

*Yes, lag still there... especially when you get a big peak.

a1ex

On 5D3, with the changeset above, audio is disabled from Canon menu but ML still can record WAV data. I didn't try on the other cameras.

But it makes sense; for this to work, sound has to be disabled while in LiveView, so the audio device doesn't get stopped by Canon code. If I disable sound manually from Canon menu, wav audio is quiet.

miyake

Now 600D code is overriding audio ic setting, and we can get sound without canon setting.
So , "canon audio disable" means only H264 without audio.
we can get WAV sound with disabled canon audio now.

We need to talk this kind of default actions.

1%

If I turn on audio and FPS override disables it I get a blank wav unless I enable audio override. 600D is kind of opposite. But this can be fixed easily, buffer issue, not sure. I looked at benchmark bin but its for 550d only and did not see a source.

/ot
I want to see if setting that wait setting to higher values or even 1,3 like its supposed to will speed up my writing. I think toshiba chip doesn't support 1.8v signaling on HSIO which is why we can't have nice things (ie UHS1 mode). But maybe can overclock bus somehow, etc.

miyake

Ah, 1%.
If you use my codes. I'm not merged current Alex's codes. You may try to use after finishing mergeing.
BTW,,, how many times I need to merge work for it? What is point of merge to main repo?


a1ex

The benchmark sources are in zebra.c, card_benchmark (if you compile with CONFIG_DEBUGMSG it should be in the menu).