Results 1 to 4 of 4

Thread: DTMF Dial V1 for Sony PSP

  1. #1
    Member
    Join Date
    Jan 2008
    Posts
    326
    Thanks
    5
    Thanked 47 Times in 24 Posts
    Rep Power
    222
    Reputation
    681

    Default DTMF Dial V1 for Sony PSP

    DTMF Dial V1

    Hi Guys,
    This is DTMF Dial V1, a user mode program that should run on many PSP firmware variations.



    DTMF Dial is a 25 entry phone book, editor, and auto dialer.
    Full instructions are included in the readme file.

    DTMF samples are 44100hz (CD quality), but I think the length of pauses need
    a fiddle for the next version.

    Rapidshare download backup link:


    Cheers, Art.



Look Here ->
  • #2
    Member
    Join Date
    Jan 2008
    Posts
    326
    Thanks
    5
    Thanked 47 Times in 24 Posts
    Rep Power
    222
    Reputation
    681

    Default

    DTMF Dial V2

    Hi Guys,
    Here is DTMF Dial V2, with phone book and editor.
    Some elements may remind you a little of X-Flash.
    A similar name editor has been added.
    The phonebook file is compatible with DTMF Dial V1,
    so you can copy the file over and just add the names.



    Nobody has posted any skins, so I decided to focus on writing in functionality.
    If you are a graphic artist interested in making a skin, download the template
    from the first release thread.

    If you like this, or my other applications, please consider a donation.
    I'm not looking for money, but low capacity Memory Sticks to aid in programming.

    Rapidshare backup link:


    Cheers, Art.

  • #3
    Junior Member
    Join Date
    Jan 2008
    Location
    IDA
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    199
    Reputation
    10

    Default

    Quote Originally Posted by Art View Post
    DTMF samples are 44100hz (CD quality), but I think the length of pauses need
    a fiddle for the next version.
    Interesting app. Strange that they use samples rather than just generating the DTMF mathematically!

  • #4
    Member
    Join Date
    Jan 2008
    Posts
    326
    Thanks
    5
    Thanked 47 Times in 24 Posts
    Rep Power
    222
    Reputation
    681

    Default

    Strange that they use samples
    "They" is me I don't release other ppls apps here.

    I modified a polyphonic code to do that, so the whole program fit in a couple of hundred K,
    the output sounds in tune with my phone DTMF tones, but didn't actually dial
    any real phone.

    I have since figured that it needs to be a sine wave rather than a triangle wave.

    Code:
    
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspaudiolib.h>
    #include <stdlib.h>
    #include <math.h>
    #include <string.h>
    #include <pspctrl.h>
    
    PSP_MODULE_INFO("DTMF", 0, 1, 1);
    PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
    
    #define printf   pspDebugScreenPrintf
    
    int ix;         // counter
    int done;      // exit flag
    
    void dump_threadstatus(void);
    
    int exit_callback(int arg1, int arg2, void *common) {
       done = 1;
       sceKernelExitGame();
       return 0;
    }
    
    int CallbackThread(SceSize args, void *argp) {
       int cbid;
       cbid = sceKernelCreateCallback("Exit Callback", (void *) exit_callback, NULL);
       sceKernelRegisterExitCallback(cbid);
       sceKernelSleepThreadCB();
       return 0;
    }
    
    
    int SetupCallbacks(void) {
       int thid = 0;
       thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
       if(thid >= 0){sceKernelStartThread(thid, 0, 0);}
       return thid;
    }
    
    int  pspAudioInit();
    void pspAudioEndPre();
    void pspAudioEnd();
    
    #define SAMPLE_COUNT 0x10000
    float sample[SAMPLE_COUNT];
    
    #define SAMPLE_RATE 44100
    #define OCTAVE_COUNT 6
    #define NOTE_END -2
    #define NOTE_PAUSE -1
    
    float octaves[OCTAVE_COUNT][12];
    
    typedef struct {
       int note;
       int octave;
       int duration;
    } Note_t;
    
    typedef struct {
       Note_t currentNote;
       int noteIndex;
       int currentTime;
       float currentsampleIndex;
       float currentsampleIncrement;
    } ChannelState_t;
    
    ChannelState_t channelStates[3];
    
    
    #define EIGHT_NOTE(note, octave, duration) { note, octave, SAMPLE_RATE * duration / 8}
    
    Note_t channel0[] = {
       EIGHT_NOTE(3, 0, 4),
       EIGHT_NOTE(0, 0, 4),
       EIGHT_NOTE(0, 0, 4),
       EIGHT_NOTE(0, 0, 4),
       EIGHT_NOTE(1, 0, 4),
       EIGHT_NOTE(1, 0, 4),
       EIGHT_NOTE(1, 0, 4),
       EIGHT_NOTE(2, 0, 4),
       EIGHT_NOTE(2, 0, 4),
       EIGHT_NOTE(2, 0, 4),
       EIGHT_NOTE(3, 0, 4),
       EIGHT_NOTE(3, 0, 4),
       EIGHT_NOTE(-1, 0, 4),
       { NOTE_END, 0, 0 }
    };
    
    Note_t channel1[] = {
       EIGHT_NOTE(5, 0, 4),
       EIGHT_NOTE(4, 0, 4),
       EIGHT_NOTE(5, 0, 4),
       EIGHT_NOTE(6, 0, 4),
       EIGHT_NOTE(4, 0, 4),
       EIGHT_NOTE(5, 0, 4),
       EIGHT_NOTE(6, 0, 4),
       EIGHT_NOTE(4, 0, 4),
       EIGHT_NOTE(5, 0, 4),
       EIGHT_NOTE(6, 0, 4),
       EIGHT_NOTE(4, 0, 4),
       EIGHT_NOTE(6, 0, 4),
       EIGHT_NOTE(-1, 0, 4),
       { NOTE_END, 0, 0 }
    };
    
    Note_t* channels[] = { channel0, channel1 };
    
    void nextNote(int channel)
    {
       ChannelState_t* state = &channelStates[channel];
       state->currentNote = channels[channel][state->noteIndex];
       state->currentTime = 0;
       state->currentsampleIndex = 0;
       int note = state->currentNote.note;
       if (note == NOTE_PAUSE) {
          state->currentsampleIncrement = 0;
       } else {
          state->currentsampleIncrement = octaves[state->currentNote.octave][note] * ((float) SAMPLE_COUNT) / ((float) SAMPLE_RATE);
       }
    
       state->noteIndex++;
       if (channels[channel][state->noteIndex].note == NOTE_END) state->noteIndex = 0;
    }
    
    // calculate current value of attack/delay/sustain/release envelope
    float adsr(float time, float duration) {
       if (time < 0.0) return 0.0;
    
       const float attack = 0.0;
       const float decay = 0.0;
       const float sustain = 0.5;
       const float release = 0.0;
    
       if (time < attack) return time / attack;
       if (time < decay) return (decay - time) / decay * (1.0 - sustain) + sustain;
       if (time < duration) return sustain;
       time -= duration;
       if (time < release) return (release - time) / release * sustain;
       return 0.0;
    }
    
    void audioOutCallback(int channel, unsigned short* buf, unsigned int reqn)
    {
       ChannelState_t* state = &channelStates[channel];
       unsigned int i;
       for (i = 0; i < reqn; i++) {
          float time = ((float) state->currentTime) / ((float) SAMPLE_RATE);
          if (state->currentTime++ == state->currentNote.duration);
    
          float value;
          if (state->currentsampleIncrement == 0.0) {
             value = 0.0;
          } else {
             value = sample[(int)state->currentsampleIndex] * adsr(time, ((float) state->currentNote.duration) / ((float) SAMPLE_RATE));
             value *= (float) 0x7000;
             state->currentsampleIndex += state->currentsampleIncrement;
             if (state->currentsampleIndex >= SAMPLE_COUNT) state->currentsampleIndex -= (float) SAMPLE_COUNT;
          }
          buf[0] = value;
          buf[1] = value;
          buf += 2;
       }
    }
    
    void audioOutCallback0(void *buf, unsigned int reqn, void *userdata) { audioOutCallback(0, buf, reqn); }
    void audioOutCallback1(void *buf, unsigned int reqn, void *userdata) { audioOutCallback(1, buf, reqn); }
    
    void createPitches(float base, float* target)
    {
          target[0] = 697;
          target[1] = 770;
          target[2] = 852;
          target[3] = 941;
          target[4] = 1209;
          target[5] = 1336;
          target[6] = 1477;
          target[7] = 1633;
          target[8] = 1;
          target[9] = 1;
          target[10] = 1;
          target[11] = 1;
          target[12] = 1;
    }
    
    int main(void)
    {
       pspDebugScreenInit();
       SetupCallbacks();
       printf("DTMF Touch Tone Generator by Art 2008!\n");
       printf("Based on Polyphonic sample by Shine\n");
    
            int i;
       int maxAt = SAMPLE_COUNT / 16;
       for (i = 0; i < SAMPLE_COUNT; i++) {
          float value;
          if (i < maxAt) {
             value = ((float) i) / ((float) maxAt) * 2.0 - 1.0;
          } else {
             value = 1.0 - ((float) (i - maxAt)) / ((float) (SAMPLE_COUNT - maxAt)) * 2.0;
          }
          sample[i] = value;
       }
       float base = 0.0;
       for (i = 0; i < OCTAVE_COUNT; i++) {
          createPitches(base, octaves[i]);
          base *= 2;
       }
    
       channelStates[0].noteIndex = 0;// nextNote(0);
       channelStates[1].noteIndex = 0;// nextNote(1);
    
       pspAudioInit();
       pspAudioSetVolume(0, 0x5000, 0x5000);
       pspAudioSetVolume(1, 0x5000, 0x5000);
       pspAudioSetChannelCallback(0, audioOutCallback0, NULL);
       pspAudioSetChannelCallback(1, audioOutCallback1, NULL);
    
    
    while (done == 0) {
             SceCtrlData xpad;
             sceCtrlSetSamplingMode(1);
             sceCtrlPeekBufferPositive(&xpad, 1);
    
             if(xpad.Buttons & PSP_CTRL_CROSS) {
             channelStates[0].noteIndex = 1;nextNote(0);
             channelStates[1].noteIndex = 1;nextNote(1);
             }
    
             if(xpad.Buttons & PSP_CTRL_CIRCLE) {
             channelStates[0].noteIndex = 2;nextNote(0);
             channelStates[1].noteIndex = 2;nextNote(1);
             }
    
             if(xpad.Buttons & PSP_CTRL_TRIANGLE) {
             channelStates[0].noteIndex = 3;nextNote(0);
             channelStates[1].noteIndex = 3;nextNote(1);
             }
    
             if(xpad.Buttons & PSP_CTRL_SQUARE) {
             channelStates[0].noteIndex = 4;nextNote(0);
             channelStates[1].noteIndex = 4;nextNote(1);
             }
    
             if(xpad.Buttons & PSP_CTRL_DOWN) {
             channelStates[0].noteIndex = 5;nextNote(0);
             channelStates[1].noteIndex = 5;nextNote(1);
             }
    
             if(xpad.Buttons & PSP_CTRL_RIGHT) {
             channelStates[0].noteIndex = 6;nextNote(0);
             channelStates[1].noteIndex = 6;nextNote(1);
             }
    
             if(xpad.Buttons & PSP_CTRL_UP) {
             channelStates[0].noteIndex = 7;nextNote(0);
             channelStates[1].noteIndex = 7;nextNote(1);
             }
    
             if(xpad.Buttons & PSP_CTRL_LEFT) {
             channelStates[0].noteIndex = 8;nextNote(0);
             channelStates[1].noteIndex = 8;nextNote(1);
             }
    
             if(xpad.Buttons & PSP_CTRL_LTRIGGER) {
             channelStates[0].noteIndex = 9;nextNote(0);
             channelStates[1].noteIndex = 9;nextNote(1);
             }
    
             if(xpad.Buttons & PSP_CTRL_RTRIGGER) {
             channelStates[0].noteIndex = 0;nextNote(0);
             channelStates[1].noteIndex = 0;nextNote(1);
             }
    
    } // while
       done = 1;
       sceKernelExitGame();
       return 0;
    }
    QFT!!!

    I figured I did the work, so I'll cheat

  • Similar Threads

    1. ***FS***Sony DSC-T70 8.1MP 2GB memory***
      By blue in forum Buy Sell and Trade
      Replies: 1
      Last Post: 03-02-08, 11:56 PM
    2. ***FS***Sony Camcorder $55.00***
      By blue in forum Buy Sell and Trade
      Replies: 16
      Last Post: 03-02-08, 11:55 PM
    3. FS:Sony Ericsson K850I
      By Hazza150 in forum Buy Sell and Trade
      Replies: 0
      Last Post: 25-01-08, 09:38 PM
    4. Sony X series lcd
      By faulty_b in forum Digital Terrestrial Television
      Replies: 2
      Last Post: 18-01-08, 10:29 AM
    5. How to unlock Sony SLV-D370P?
      By jmarck122 in forum Sound/Visual/Digital Multimedia
      Replies: 2
      Last Post: 09-01-08, 07:29 PM

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •