Sound                package:R.audio                R Documentation

_S_o_u_n_d _c_l_i_e_n_t _f_o_r _r_e_m_o_t_e _o_r _l_o_c_a_l _S_o_u_n_d _a_c_c_e_s_s

_D_e_s_c_r_i_p_t_i_o_n:

     Package:  R.audio 
      *Class Sound*

     'Object'
      '~~|'
      '~~+--''Sound'

     *Directly known subclasses:*


     public static class *Sound*
      extends Object

_U_s_a_g_e:

     Sound(samples=NULL, samplesPerSecond=NULL, bitsPerSample=NULL, signed=TRUE)

_A_r_g_u_m_e_n_t_s:

 samples: 

samplesPerSecond: Samples per second.

bitsPerSample: Number of bits per sample to use.

  signed: If 'TRUE', signed 'integer's are used, otherwise not.

_F_i_e_l_d_s _a_n_d _M_e_t_h_o_d_s:

     *Methods:*

         'as.character'       -
         'avgBytesPerSecond'  -
         'bitsPerSample'      -
         'fft'                -
         'generateTone'       -
         'nbrOfChannels'      -
         'nbrOfSamples'       -
         'nbrOfSeconds'       -
         'periodogram'        -
         'play'               -
         'playStop'           -
         'plot'               -
         'plotPeriodogram'    -
         'read'               -
         'readAU'             -
         'readWAV'            -
         'reverse'            -
         'samplesPerSecond'   -
         'write'              -
         'writeAU'            -
         'writeWAV'           -

     *Methods inherited from Object*:
      $, $<-, [[, [[<-, as.character, attach, attachLocally,
     clearCache, clone, detach, equals, extend, finalize, gc,
     getEnvironment, getFields, getInstanciationTime,
     getStaticInstance, hasField, hashCode, ll, load, objectSize,
     print, save

_A_u_t_h_o_r(_s):

     Henrik Bengtsson (<URL: http://www.braju.com/R/>)

_E_x_a_m_p_l_e_s:

     ## Not run: # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Load all audio files found in the data directory of this package
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     path <- system.file("sounds", package="R.audio")
     files <- list.files(path, pattern="[.](au|wav)$", full.names=TRUE)

     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Play the sounds
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     for (file in files) {
       cat(file, " - ", sep="");
       sound <- Sound$read(file, verbose=F)
       print(sound)
       plot(sound, main=file, cex.main=0.8)
       play(sound)
     }

     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Generate new sounds from scratch
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Create a 3 seconds (8-bit) 1000Hz tone (with 22500 samples/s)
     s1 <- Sound$generateTone(1000, nbrOfSeconds=3)
     # Create a 3 seconds (8-bit) 1002Hz tone (with 22500 samples/s)
     s2 <- Sound$generateTone(1002, nbrOfSeconds=3)
     # Mix them together. Notice wowing effect of 2Hz == (1002-1000)Hz
     s <- clone(s1)
     paste(s, s2)

     # Display the sound graphically
     plot(s)
     ## End(Not run)

