Changeset 2369 for pjproject


Ignore:
Timestamp:
Nov 19, 2008 2:48:48 PM (16 years ago)
Author:
bennylp
Message:

Small modifications to level.c sample to print out the timeline and linear level

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/samples/level.c

    r2039 r2369  
    7373int main(int argc, char *argv[]) 
    7474{ 
    75     enum { NSAMPLES = 160, COUNT=100 }; 
     75    enum { NSAMPLES = 640, COUNT=100 }; 
    7676    pj_caching_pool cp; 
    7777    pjmedia_endpt *med_endpt; 
     
    124124    } 
    125125 
     126    if (file_port->info.samples_per_frame > NSAMPLES) { 
     127        app_perror(THIS_FILE, "WAV clock rate is too big", PJ_EINVAL); 
     128        return 1; 
     129    } 
     130 
     131    puts("Time\tPCMU\tLinear"); 
     132    puts("------------------------"); 
     133 
    126134    for (i=0; i<COUNT; ++i) { 
    127135        pj_int16_t framebuf[NSAMPLES]; 
    128136        pjmedia_frame frm; 
    129137        pj_int32_t level32; 
     138        unsigned ms; 
    130139        int level; 
    131140 
     
    135144        pjmedia_port_get_frame(file_port, &frm); 
    136145 
    137         level32 = pjmedia_calc_avg_signal( framebuf, NSAMPLES ); 
     146        level32 = pjmedia_calc_avg_signal(framebuf,  
     147                                          file_port->info.samples_per_frame); 
    138148        level = pjmedia_linear2ulaw(level32) ^ 0xFF; 
    139149 
    140         printf("%d ", level); 
     150        ms = i * 1000 * file_port->info.samples_per_frame / 
     151                        file_port->info.clock_rate; 
     152        printf("%03d.%03d\t%7d\t%7d\n",  
     153                ms/1000, ms%1000, level, level32); 
    141154    } 
    142155    puts(""); 
Note: See TracChangeset for help on using the changeset viewer.