Better frequency block

This just creates a sound with the frequency (sine waves) you enter. The difference is that this is a lot faster than the library one. These are some examples.


Source

Copy & Import:

<blocks app="Snap! 7, https://snap.berkeley.edu" version="2"><block-definition s="frequency %&apos;freq&apos; Hz for %&apos;secs&apos; secs at %&apos;rate&apos; Hz" type="reporter" category="sound"><header></header><code></code><translations></translations><inputs><input type="%n">440</input><input type="%n">1</input><input type="%n">44100<options>22.05 kHz=22050&#xD;44.1 kHz=44100&#xD;48 kHz=48000&#xD;88.2 kHz=88200&#xD;96 Hz=96000</options></input></inputs><script><block s="doReport"><block s="reportNewSoundFromSamples"><block s="reportReshape"><block s="reportMonadic"><l><option>sin</option></l><block s="reportQuotient"><block s="reportVariadicProduct"><list><block s="reportNumbers"><l>1</l><block s="reportQuotient"><block var="rate"/><block var="freq"/></block></block><block var="freq"/><l>360</l></list></block><block var="rate"/></block></block><list><block s="reportMonadic"><l><option>ceiling</option></l><block s="reportVariadicProduct"><list><block var="secs"/><block var="rate"/></list></block></block></list></block><block var="rate"/></block></block></script></block-definition></blocks>

(C) 2022 ScratchModification

Cool. I'd be tempted to generalize it by adding a SHAPE input, default SIN, but it takes an arbitrary function as input, so you can make sawteeth or whatever.

This isn't your issue, because the primitive sound blocks do it too, but I am suddenly moved to wonder whether "Hz" is really the correct unit for the sampling rate. It's samples per second, not cycles per second. Some digital musician want to straighten me out about this?

Yes, it's correct.

Cmon... Nobody wants to have to create a file, copy text into it, then open it up in a project.

agreed, thank you.

Ya know, im starting to appreciate @scratchmodification copy and import thing because I cant access the projects while at home

I'm always trying to innovate manners to change Snap! :wink:

oh, ok