Anyone find any Sound Events / Recording Access? - page 2 - Feature Requests - CHDK Forum

Anyone find any Sound Events / Recording Access?

  • 20 Replies
  • 15396 Views
*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Anyone find any Sound Events / Recording Access?
« Reply #10 on: 14 / July / 2008, 06:56:59 »
Advertisements
uhm, thanks for hijacking the thread. i merely asked how to activate sounds, you asked how to deactivate sounds ;)
ewavr, got any clues about this?

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Anyone find any Sound Events / Recording Access?
« Reply #11 on: 26 / July / 2008, 13:57:36 »
Maybe function for playing different camera sounds can be useful for script writers.

PT_PlaySound(short sound, void* cb_on_end_of_play);
where cb_on_end_of_play is pointer to function (maybe void (void)) called on end of play or NULL,
sound is one of internal camera sounds:
0x2001 - startup sound
0x2002 - shutter sound
0x2003 - button press sound
0x2004 - self-timer sound
0xC211, 0xC20A, 0xC210 - short beep
0x400D - continuous "beeee"
0xC507 - ??
and experimentally found 50000 - AF confirmation

okay, with my newly found "passion" for asm i managed to find this function in the s3is dump. wasn't that hard actually, i guess it will be easy for the other cams as well.
BUT, how do i actually get it into CHDK? i mean especially the "void* cb_on_end_of_play" bit, is cb_on_end_of_play an actual function? didnt find it in the names list of IDA, i guess it is just a replacement name by you. Can you give an example implementation for the S3is so i can replay it on my box and do it again for other cameras, please?

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Anyone find any Sound Events / Recording Access?
« Reply #12 on: 26 / July / 2008, 14:43:02 »
For the beginning, simpy use NULL instead of callback function.

_PT_PlaySound(2001, NULL); // plays startup sound

However, callback function can be useful, for example, for busy flag handling (just for reference, not tested):

volatile int sound_busy=0;

void sound_callback(void){
 sound_busy=0;
}

void play_sound(short sound){
 while (sound_busy) _SleepTask(10);
 sound_busy=1;
 _PT_PlaySound(sound, sound_callback);
}

If we call play_sound() while previous sound is played, it waits for  previous sound termination, starts new sound playing and exits immediately. At end of play some OS task (which plays sound) calls our function sound_callback(), which resets sound_busy flag.

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Anyone find any Sound Events / Recording Access?
« Reply #13 on: 26 / July / 2008, 17:43:07 »
i royally failed in doing it. i think i am too stupid :D

this is what i did: Diff pastecode - collaborative debugging tool
this is about the 100th version i did, it maybe is the most stupid thing you ever read. please dont be harsh on me, ewavr :D
at one point it compiled, but when i executed the function, the cam crashed. i dont know how to continue. :(

sorry, in the diff there is not only playsound but the temperaturestuff, ignore it :D
« Last Edit: 26 / July / 2008, 17:45:06 by PhyrePhoX »

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Anyone find any Sound Events / Recording Access?
« Reply #14 on: 27 / July / 2008, 16:38:00 »
Try also
NHSTUB(PT_PlaySound, 0xFFB3163C)

Correct prototype:
void _PT_PlaySound(short , void*); 

but this cannot crash camera. Main error is:

play_sound(2001)

not 2001, but 0x2001 !

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Anyone find any Sound Events / Recording Access?
« Reply #15 on: 27 / July / 2008, 18:16:27 »
thanks! now i managed that it actually works. using this patch and the right adress.

Diff pastecode - collaborative debugging tool

thanks!

by the way, using BOTH adresses worked, though i can find the first one much faster.
note: the camera MUST NOT be set to MUTE (had it muted at first, thats why i didnt realize it is already working, i'm so stupid :D) - also: you HAVE TO Set sounds in the custom menu, so for example for the startsound, it will only be played if you can hear it when you start the cam. (maybe we can also find a way to UNMUTE the cam when you play the sound, so you dont have to start the cam unmuted)
using this patch on juciphox you can play the startsound when you press UP when you enable the fast ev switch in the photo overrides menu (this is just ALPHA).

fine, now i only have to search the adresses for temperature & playsound in IDA.
thanks ewavr (maybe you can have a look in my patch if i did the actual implementation right!?), many many thanks!

todo: find adresses, clean up, implement it to be used in script.

by the way ewavr, i think we dont need the clear function, i can play the sound continuially, meaning: i can hit the UP button (in my example code) multiple time, the sound is played everytime even though the old one wasnt finished (of course you dont hear the two simultaneously)
« Last Edit: 27 / July / 2008, 18:20:39 by PhyrePhoX »

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Anyone find any Sound Events / Recording Access?
« Reply #16 on: 28 / July / 2008, 20:54:03 »
Quote
0x400D - continuous "beeee"
interesting, 400D :D one thing i noticed about this: it can be played with the others at the same time! Also, the beep will NOT stop, unless you play another sound, but it doesnt stop instantly, have to find out how and when it does stop to be able to reproduce it.
while coding the implementation i sometimes felt like a DiskJockey (used canons crappy default sounds with the bird and the dog and so on, like on a cheap keyboard with the effects buttons jammed up :D). this BEEP will come in handy in anti-theft protection ;)
anyhow, i implemented it this way:

Code: (c) [Select]
void play_sound(short sound)
{
short tmp;
    switch (sound)
{
  case 0:
    tmp = 0x2001; //startup sound
    break;
  case 1:
    tmp = 0x2002; //shutter sound
    break;
  case 2:
    tmp = 0x2003; //button press sound
    break;
  case 3:
    tmp = 0x2004; //self-timer sound
    break;
  case 4:
   tmp = 0xC211; //short beep
    break;
  case 5:
   tmp = 50000; // AF confirmation
    break;
  case 6:
   tmp = 0xC507; // error beep imo
    break;
  case 7:
   tmp = 0x400D; // LONG ERROR BEEP CONTINIUOUS- warning, cannot be stopped (yet)
    break;
 }
    _PT_PlaySound(tmp, 0);
}
and i can also call this from ubasic via "playsound 1" for example.

notice that you have to enable the sounds in the customizing menu and also set each sound so that it isnt muted in the menu. we might find a way to unmute sound before or while playing sound via ubasic.

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Anyone find any Sound Events / Recording Access?
« Reply #17 on: 03 / August / 2008, 14:02:29 »
hm, there is a string _MuteOn and a string _MuteOff, can we perhaps find a function to mute/unmute the camera?
so in script we can do something like

mute 1 //mutes the cam
press button //wont produce sound
mute 0 //unmutes cam
playsound 1 //plays sound, for example in a counter or for other things
mute 1
...

i call unto the gods of chdk & asm. please help ;)

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Anyone find any Sound Events / Recording Access?
« Reply #18 on: 04 / August / 2008, 17:59:24 »
hm, there is a string _MuteOn and a string _MuteOff, can we perhaps find a function to mute/unmute the camera?
so in script we can do something like

mute 1 //mutes the cam
press button //wont produce sound
mute 0 //unmutes cam
playsound 1 //plays sound, for example in a counter or for other things
mute 1
...

i call unto the gods of chdk & asm. please help ;)


Erm well you didn't say which firmware that screenshot came from, but for my camera I'd try

a570is 1.00e
ffc1854c _MuteOn
ffc18598 _MuteOff
and even before that I'd take a look at RAM address 0x2414, which looks like it's 1 when muted, 0 when not muted. It might be a good idea to monitor it before calling those functions in order to find exactly what "Mute" means in this context.

I didn't try any of this. Writing to that RAM address will not mute/unmute as far as I can guess, but changing it's value outside these functions may prevent the camera from muting an unmuted camera and vice versa by making it think it's been muted/unmuted).

For your screenshot, I'd try monitoring the memory address 0x7968 for the same exact behavior and use 0xff9c5048 for entry point to _MuteOff and 0xff9c4ffc for _MuteOn entry point.


*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Anyone find any Sound Events / Recording Access?
« Reply #19 on: 04 / August / 2008, 19:07:20 »
thanks, will look into it! did you have a look on the other thread about the evf compensation tutorial you wrote? got a question there. it all boils down to me being such a lame asm reader :D
btw, is there any reason you dont actively code besides scripts? you seem to have the knowledge to find out a lot of the inner workings of these cameras. so i assume.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal