Hello All:

(Cross posted to the wxperl-users mailing list)

Awhile back I was working on some wxPerl code to simulate an o-scope display screen. While the original requirement that started me down that path went away, I did get a proof of concept working that displayed several waveforms and a four channel logic analyser(animated). I have also been playing with the Gqrx software defined radio package and developed a wxPerl based Gqrx scanner application plug-in. A request was made on the Gqrx google group for a method to display the raw audio waveform. It sounded like a good challenge. Gqrx outputs one channel of 16-bit, 48KHz audio to a UDP port. I have this working with a scrolling audio waveform on the o-scope screen. I wonder, and it's hard to tell, if the display is keeping up with the 48KHz data stream. Am I dropping packets? Can I speed up the display process using a memory file rather than writing to a disk file? Will Wx support this? This is the current display and refresh code.

# Create the Display(bmp & sbm) and Drawing(image) Objects # Uses GD calls to draw the screen background and waveform on t +he image object $self->{bmp} = Wx::Bitmap->new("rawaudio.png", wxBITMAP_TYPE_PNG); $self->{sbm} = Wx::StaticBitmap->new($self, wxID_ANY, $self->{bmp} +, wxDefaultPosition, [600,600]); $oscope->{image} = GD::Image->new($oscope->{maxw}, $oscope->{maxh} +) || die; # Read the updated image and refresh the display $self->{bmp} = Wx::Bitmap->new("rawaudio.png", wxBITMAP_TYPE_PNG); + # Reload the screen image $self->{sbm}->SetBitmap($self->{bmp}); # Refresh sc +reen # Save the Drawing Object to a disk file my $png_data = $oscope->{image}->png; # Write image + to a file open OUTFILE, ">", "rawaudio.png" || die; binmode OUTFILE; print OUTFILE $png_data; close OUTFILE;
Can this code be modified to use a memory file? Syntax? I am also considering moving the socket code into it's own thread to isolate the reading and decoding of the UDP packets from the updating of the display. Thanks in advance,

Update:

I now have a fairly functional raw audio display script. I still don't know if I am dropping any packets. I am considering developing a UDP server script to feed controlled waveform packets to my script to help to resolve this question. See jmlynesjr for a snapshot of the screen. I will post the code to CUFP later as another wxPerl example. It was a good learning experience for using and decoding/unpacking UDP packets, writing to memory files, and for reusing my simulated o-scope code. Dereferencing lists and arrays inside hashes gave me trouble and I may post a follow-up question after a little more reading on the topic.

James

There's never enough time to do it right, but always enough time to do it over...


In reply to Memory File and wxPerl by jmlynesjr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.