Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 23 Apr 2014, 19:35
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
How to customize Snack sound generator freq. increment
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
Rhino


Joined: 04 May 2005
Posts: 262
Location: Cincinnati, OH, USA

PostPosted: Thu 09 Mar 2006, 19:20    Post subject:  How to customize Snack sound generator freq. increment  

I used the snack sound generator in Puppy today in class and it worked great to demonstrate changes in frequency and amplitude for waves on an oscilloscope. I just put the mic close to my pc speaker and a beautiful wave appeared on the oscilloscope..very nice.

I wanted to demonstrate beats due to consructive and destructive interference of the waves by having another adjacent pc producing a sound at a slightly different frequency. However, when I adjust the frequency it changes by about 12 Hz, I need it to be only 1-2 Hz to see and hear the beats well.

I had a look at the code for the application (sgenerator.tcl...I think), but I couldn't figure out how to change the frequency so that it is adjustable in 1Hz increments. If it is possible to do this, it could be a useful change to sgenerator in all future versions of Puppy.

Please let me know if it is possible to get it to produce 1 Hz intervals. Thanks!

_________________
Visit the Puppy Linux Video Tutorials @ http://rhinoweb.us
Back to top
View user's profile Send private message Yahoo Messenger 
Rhino


Joined: 04 May 2005
Posts: 262
Location: Cincinnati, OH, USA

PostPosted: Thu 09 Mar 2006, 21:56    Post subject:  

OK, I solved my own problem, but may be it will be useful for others.

Code:

pack [frame .f] -expand yes -fill both -side top
pack [scale .f.s1 -label Frequency -from 1000 -to 50 -length 800\
        -variable v(freq) -command Config] -side left -expand yes -fill both
pack [scale .f.s2 -label Amplitude -from 32767 -to 0 -length 800\
        -variable v(ampl) -command Config] -side left -expand yes -fill both



To get the frequency to change in 1 Hz increments, I just decreased the maximum frequency to 1000Hz, but you could make it lower if you like to get a slightly smaller window. I also changed the length of the bar to 800 rather than the original so the box is much longer. I also changed the bar length to 800 to make it match as well.

If you have a different screen resolution, it may help to keep the bar length shorter, but to simply decrease the maximum frequency to something like 600 Hz.

I may attempt to figure out how to turn the whole box horizontally to maximize the screen space available to have a larger range of frequencies and 1Hz resolution.[/code]

_________________
Visit the Puppy Linux Video Tutorials @ http://rhinoweb.us
Back to top
View user's profile Send private message Yahoo Messenger 
Rhino


Joined: 04 May 2005
Posts: 262
Location: Cincinnati, OH, USA

PostPosted: Thu 09 Mar 2006, 22:52    Post subject:  

I changed the orientation of the slider bars in the tone generator so they will be horizontal to privide a little more space and resized the scale so that it would display and make 1Hz increments. I found that you can increase the maximum frequency, however, you might have to maximize the window to see it.

I know this is probably a little used application, but for me it is excellent for Physics class.


Code:
#!/bin/sh
# the next line restarts using wish \
exec wish8.4 "$0" "$@"

package require -exact snack 2.2

set f [snack::filter generator 440.0]
snack::sound s
#snack::audio playLatency 200

tk_optionMenu .m v(type) sine rectangle triangle sawtooth noise
foreach i [list 0 1 2 3 4] {
  .m.menu entryconfigure $i -command Config
}
pack .m -side bottom

pack [frame .fb] -side bottom
pack [button .fb.a -bitmap snackPlay -command Play] -side left
pack [button .fb.b -bitmap snackStop -command "s stop"] -side left

set v(freq) 440.0
set v(ampl) 20000

pack [frame .f] -expand yes -fill both -side top
pack [scale .f#!/bin/sh
# the next line restarts using wish \
exec wish8.4 "$0" "$@"

package require -exact snack 2.2

set f [snack::filter generator 440.0]
snack::sound s
#snack::audio playLatency 200

tk_optionMenu .m v(type) sine rectangle triangle sawtooth noise
foreach i [list 0 1 2 3 4] {
  .m.menu entryconfigure $i -command Config
}
pack .m -side bottom

pack [frame .fb] -side bottom
pack [button .fb.a -bitmap snackPlay -command Play] -side left
pack [button .fb.b -bitmap snackStop -command "s stop"] -side left

set v(freq) 440.0
set v(ampl) 20000

pack [frame .f] -expand yes -fill both -side top
pack [scale .f.s1 -orient horizontal -label Frequency -from 100 -to 1500 -length 1200\
        -variable v(freq) -command Config] -side top -expand yes -fill both
pack [scale .f.s2 -orient horizontal -label Amplitude -from 0 -to 3267 -length 1200\
        -variable v(ampl) -command Config] -side top -expand yes -fill both

proc Config {args} {
  global f v
  set shape 0.0
  set type $v(type)
  switch $type {
    sine {
      set shape 0.0
    }
    rectangle {
      set shape 0.5
    }
    triangle {
      set shape 0.5
    }
    sawtooth {
      set shape 0.0
      set type triangle
    }
  }
  $f configure $v(freq) $v(ampl) $shape $type -1
}

proc Play {} {
  global f
  s stop
  s play -filter $f
}
.s1 -orient horizontal -label Frequency -from 100 -to 1500 -length 1200\
        -variable v(freq) -command Config] -side top -expand yes -fill both
pack [scale .f.s2 -orient horizontal -label Amplitude -from 0 -to 3267 -length 1200\
        -variable v(ampl) -command Config] -side top -expand yes -fill both

proc Config {args} {
  global f v
  set shape 0.0
  set type $v(type)
  switch $type {
    sine {
      set shape 0.0
    }
    rectangle {
      set shape 0.5
    }
    triangle {
      set shape 0.5
    }
    sawtooth {
      set shape 0.0
      set type triangle
    }
  }
  $f configure $v(freq) $v(ampl) $shape $type -1
}

proc Play {} {
  global f
  s stop
  s play -filter $f
}

_________________
Visit the Puppy Linux Video Tutorials @ http://rhinoweb.us
Back to top
View user's profile Send private message Yahoo Messenger 
HaJo

Joined: 14 Mar 2006
Posts: 27
Location: DE

PostPosted: Sat 25 Mar 2006, 10:07    Post subject:  

Rhino wrote:
Code:
...
pack [frame .f] -expand yes -fill both -side top
pack [scale .f#!/bin/sh
--------------^^...

This looks like a cut+paste - accident

_________________
-HaJo
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0522s ][ Queries: 11 (0.0044s) ][ GZIP on ]