Programmer Guide/Shell Items/Wave/WAVE Item Examples: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
mNo edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
==WAVE item examples==
{{Wave Item}}


The following example displays a wave's samples in a list box.
The following example displays a wave's samples in a list box.
Line 22: Line 22:
     #wave := new wave * 1_$#nsamples
     #wave := new wave * 1_$#nsamples
     if '$#wave[?]' != 'wave' em -1 ; wave creation failed ($emsg)
     if '$#wave[?]' != 'wave' em -1 ; wave creation failed ($emsg)
        //
    //
        // create table to receive wave data
    // create table to receive wave data
        //
    //
        #table := new table * /Parameter $#nch num
    #table := new table * /Parameter $#nch num
     //
     //
     // play the contents of the soundfile
     // play the contents of the soundfile
     //
     //
     $#wave copy $#table /Write
     $#wave copy $#table /Write
        //
    //
        // display wave contents in table
    // display wave contents in table
        //
    //
        showitem $#table
    showitem $#table
     //
     //
     // use message box to prevent script from ending
     // use message box to prevent script from ending

Latest revision as of 08:11, 5 May 2015

Wave Item
INTRODUCTION NEW SET ATTRIBUTES MESSAGES EXAMPLES

The following example displays a wave's samples in a list box.

[macro wave_item_table_data_example]
    //
    // ask user to select a soundfile from disk
    //
    #sf := butil 'FileDialog open ; Select a soundfile'
    if '$#sf' == '' exit
    //
    // load the soundfile in STx
    //
    load soundfile '$#sf' /Read
    if '$rc' > 0 em $rc ; LOAD SOUNDFILE failed ($emsg)
    readvar csfh #srate #nch #nsamples #code #type #mode
    //
    // create a wave item addressing the soundfile
    //
    #wave := new wave * 1_$#nsamples
    if '$#wave[?]' != 'wave' em -1 ; wave creation failed ($emsg)
    //
    // create table to receive wave data
    //
    #table := new table * /Parameter $#nch num
    //
    // play the contents of the soundfile
    //
    $#wave copy $#table /Write
    //
    // display wave contents in table
    //
    showitem $#table
    //
    // use message box to prevent script from ending
    //
    um 'Do you want to exit?'
    //
    // clean up
    //
    delete $#wave $#table
exit

Navigation menu

Personal tools