Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add More Frequent "RUN LIVE" Links to Music Blocks Programming Guide #3999

Merged
merged 3 commits into from
Sep 15, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,15 @@ case, an eighth note.
At the bottom, two notes that are played consecutively are shown. They
are both `1/8` notes, making the duration of the entire sequence
`1/4`.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725793425037300&run=True)


![notes](./note2.svg "A quarter note, a sixteenth note, and a half note Note value blocks")

In this example, different note values are shown. From top to bottom,
they are: `1/4` for an quarter note, `1/16` for a sixteenth note, and
`1/2` for a half note.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725793536240960&run=True)

Note that any mathematical operations can be used as input to the
*Note value*.
Expand Down Expand Up @@ -236,13 +239,15 @@ notes are located on a keyboard or staff.
Multiple, simultaneous pitches can be specified by adding multiple
*Pitch* blocks into a single *Note value* block, like the above
example.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725793652385126&run=True)

### <a name="RESTS">2.4 Rests</a>

![silence block](./silence.svg "Silence blocks create rests")

A rest of the specified note value duration can be constructed using a
*Silence* block in place of a *Pitch* block.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725793737126028&run=True)

### <a name="DRUMS">2.5 Drums</a>

Expand All @@ -252,12 +257,14 @@ Anywhere a *Pitch* block can be used&mdash;e.g., inside of the matrix
or a *Note value* block&mdash;a *Drum Sample* block can also be used
instead. Currently there about two dozen different samples from which
to choose. The default drum is a kick drum.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725793852737369&run=True)

![drums](./note5.svg "Multiple Drum Sample blocks in combinations")

Just as in the [multi-pitch](#23-multiple-pitches) example above, you
can use multiple *Drum* blocks within a single *Note value* blocks,
and combine them with *Pitch* blocks as well.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725793935277059&run=True)

## <a name="PROGRAMMING-WITH-MUSIC">3. Programming with Music</a>

Expand All @@ -275,6 +282,8 @@ widget to help you get started.

![action](./chunk-1.svg "using action inside Start block")

[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725788353457649&run=True)

Every time you create a new *Action* stack, Music Blocks creates a new
block specific to, and linked with, that stack. (The new block is
found at the top of the *Block* palette, found on the left edge of the
Expand Down Expand Up @@ -311,13 +320,15 @@ block to execute them sequentially.

You can [repeat](#333-repeating-notes) actions either by using
multiple *Action* blocks or using a *Repeat* block.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725788849659637&run=True)

![multiple actions](./chunk-6.svg "multiple action stacks")

![mixing actions](./chunk-5.svg "mixing and matching chunks")

You can also mix and match actions. Here we play the *Action* block with
name `chunk0`, followed by `chunk1` twice, and then `chunk0` again.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725789807251793&run=True)

![actions](./chunk-8.svg "creating a song using actions")

Expand All @@ -326,6 +337,8 @@ name `chunk0`, followed by `chunk1` twice, and then `chunk0` again.
A few more chunks and we can make a song. (Can you read the block
notation well enough to guess the outcome? Are you familiar with the
song we created?)
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725791527821787&run=True)


### <a name="PITCH-TRANSFORMATION">3.2 Pitch Transformations</a>

Expand Down Expand Up @@ -1101,10 +1114,14 @@ In the example, on the left, the result would be `Sol, Re, Sol, Sol,
Re, Sol, Sol, Re, Sol, Sol, Re, Sol`; on the right the result would be
`Sol, Sol, Sol, Sol, Re, Re, Re, Re, Sol, Sol, Sol, Sol`.

[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725794018017026&run=True)

#### <a name="SWINGING">3.3.4 Swinging Notes and Tied Notes</a>

![swing](./transform7.svg "swinging notes and tied notes")

[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725867425283695&run=True)

The *Swing* block works on pairs of notes (specified by note value),
adding some duration (specified by swing value) to the first note and
taking the same amount from the second note. Notes that do not match
Expand Down Expand Up @@ -1165,6 +1182,8 @@ The *Slur* block lengthens the sustain of notes&mdash;running longer than
the noted duration and blending it into the next note&mdash;while
maintaining the specified rhythmic value of the notes.

[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725868210212676&run=True)

#### <a name="BACKWARDS">3.3.7 Backwards</a>

![backwards](./transform11.svg "Backward block")
Expand Down Expand Up @@ -1213,6 +1232,8 @@ example, if you have 3 notes in sequence contained in a *Crescendo*
block with a value of `5`, the final note will be at 15% more
than the original value for volume.

[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725868641106995&run=True)

NOTE: The *Crescendo* block does not alter the volume of a note as it
is being played. Music Blocks does not yet have this functionality.

Expand All @@ -1224,7 +1245,7 @@ The default instrument is an electronic synthesizer, so by default,
that is the instrument used when playing notes. You can override this
default for a group of notes by using the *Set Instrument* block. It
will select an [instrument](#342-setting-instrument) for the
synthesizer for any contained blocks, e.g., violin.
synthesizer for any contained blocks, e.g., violin. [RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725869548034418&run=True)

![default voice](../documentation/setdefaultinstrument_block.svg "Set Default Instrument")

Expand All @@ -1233,6 +1254,7 @@ block. In the example above, the default instrument is set to piano,
so any note that is not inside of a *Set instrument* block will be
played using the piano synthesizer. The first note in this example is
piano; the second note is guitar; and the third is piano.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725869737763127&run=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked at all of these examples, but I did look at this one. The example you generated does not match the text or illustration. Please double check these live examples.

Copy link
Contributor Author

@dubeanant dubeanant Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @walterbender,

I checked the "RUN LIVE" link and found that I am unable to use the "Set Default Instrument" block. Whenever I select it, the block is converted to an "Unknown" block.
Screenshot 2024-09-10 224437

As for the other link, I will double-check it tomorrow and create a pull request again.

Copy link
Contributor Author

@dubeanant dubeanant Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also @walterbender , could you please advise on what to do about this "RUN LIVE" link? I am currently unable to use "set default instrument" block.

https://musicblocks.sugarlabs.org/index.html?id=1725869737763127&run=True

This is my first open-source contribution, so I apologize for any mistakes I may have made. I would greatly appreciate your guidance and support on this journey.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. There seems to be a regression with the set default instrument block. We'll have to sort it out. Maybe leave that example out of your PR, since it is not correct? And maybe you can write up an issue on the broken block?

In general, your PR is very nice. But it is only by chance that I picked up on the errant example. In the future, it would be good to make a note of such discrepancies in your commit message or PR description.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, once you create the issue, maybe try to fix the regression? A quick look at js/blocks/ToneBlocks.js reveals that the macro definition for setdefaultinstrument is using the wrong block name. Should be an easy fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @walterbender ,
I have raised the regression issue, but I'm unable to solve it because I can't open the Music Blocks project on my localhost. I have tried everything but it just load, and it was working two days ago, but now it's not opening. Until this problem is resolved, I don't think I'll be able to contribute to any issues other than documentation.

Screen.Recording.2024-09-12.105305.mp4

Could you please guide me on what to do to open the Music Blocks project on my localhost again?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you trying from a local server or directly from index.html? Can you share any console output? Are you sure that you have the current master on your machine?

Copy link
Contributor Author

@dubeanant dubeanant Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes @walterbender , I have tried running it multiple times on my local server, and there are no errors in my console. I also tried the same setup on another laptop, and it worked, but I’m not sure why it's not working on mine.

Additionally, I have added some new links to the documentation and double-checked the other live links, so you can review it again and let me know if there are any issues with my PR this time. I have assigned the regression issue to @omsuneri due to the current problem with my laptop.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try running by opening the file (index.html) directly from your browser. You should see errors in the console if it doesn't load properly. (The fact that it worked on another machine makes me think that perhaps the version you are running is not up-to-date with the master branch. What is the last commit on master you are seeing?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried running the project by opening the file (index.html) directly from my browser, but I am still having the same problem. One of the main issues is that I cannot open the console while it's loading. The last commit I made on the master branch was today, with the message "Added new RUN LIVE links."
Screenshot 2024-09-12 210005


#### <a name= "SETTINGKEY"></a>3.4.3 Setting Key and Mode

Expand All @@ -1245,6 +1267,7 @@ and a number of more exotic modes, such as Bebop, Geez, Maqam, etc.
This block allows users to access "movable Do" within Music Blocks,
where the mapping of solfege to particular pitch changes depending on
the user's specified tonality.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725870361330836&run=True)

![mode](./transform19.svg "Define mode block")

Expand All @@ -1262,6 +1285,7 @@ e.g. plus or minus up to one half step. The rate argument determines
the rate of the variation.

The other effects blocks also modulate pitch over time. Give them a try.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725870963978517&run=True)

### <a name="VOICES">3.5 Voices</a>

Expand Down Expand Up @@ -1686,6 +1710,7 @@ You can use as many *Rhythm* blocks as you'd like inside the
*Phrase maker* block. In the above example, two *Rhythm*
blocks are used, resulting in three quarter notes and six eighth
notes.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725873372253840&run=True)

#### <a name="CREATING-TUPLETS">4.2.3 Creating Tuplets</a>

Expand All @@ -1695,7 +1720,7 @@ notes.

Tuplets are a collection of notes that get scaled to a specific
duration. Using tuplets makes it easy to create groups of notes that
are not based on a power of 2.
are not based on a power of 2 [RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725874435939635&run=True).

In the example above, three quarter notes&mdash;defined in the *Simple
Tuplet* block&mdash;are played in the time of a single quarter
Expand All @@ -1717,6 +1742,7 @@ for intermixing multiple rhythms within single tuplet.

In the example above, the two *Rhythm* blocks are embedded in the
*Tuplet* block, resulting in a more complex rhythm.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725874743559698&run=True)

Note: You can mix and match *Rhythm* blocks and *Tuplet* blocks when
defining your matrix.
Expand Down Expand Up @@ -1813,6 +1839,7 @@ sub-cells. Once the fourth tone has sounded, a progress bar will run
from left to right across the screen. Each click of the mouse will
define another beat within the cell. If you don't like your rhythm,
use the *Undo* button and try again.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725875683911786&run=True)

### <a name="modes">4.4 Musical Modes</a>

Expand Down Expand Up @@ -1901,6 +1928,7 @@ Note: The build-in modes in Music Blocks can be found in [musicutils.js](https:/

The *Save* button exports a stack of blocks representing the mode that
can be used inside the *Phrase maker* block.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725877046734200&run=True)

### <a name="meters">4.5 Meters</a>

Expand Down Expand Up @@ -2245,6 +2273,8 @@ The *Drag* button will drag the widget.

The *Close* button will close the widget.

[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725879922065766&run=True)

### <a name="oscilloscope">4.13 The Oscilloscope</a>

Music Blocks has an Oscilloscope Widget to visualize the music as it plays.
Expand All @@ -2254,6 +2284,7 @@ Music Blocks has an Oscilloscope Widget to visualize the music as it plays.
![widget](./oscilloscope2.svg "Oscilloscope")

A separate wave will be displayed for each mouse.
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725883406989554&run=True)

### <a name="sampler">4.14 The Sampler</a>

Expand All @@ -2270,6 +2301,8 @@ Instrument* block.

![widget](./sampler2.svg "Sampler Widget")

[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725883527894966&run=True)

### <a name="arpeggio">4.15 Arpeggio</a>

![widget](../documentation/arpeggiomatrix_block.svg "Arpeggio Widget")
Expand All @@ -2295,6 +2328,8 @@ do do sol```.

![widget](../documentation/custom_arpeggio.svg "Custom Arpeggio")

[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725883915389933&run=True)

## <a name="BEYOND-MUSIC-BLOCKS">5. Beyond Music Blocks</a>

[Previous Section (4. Widgets)](#4-widgets) | [Back to Table of Contents](#TABLE-OF-CONTENTS)
Expand Down Expand Up @@ -2401,6 +2436,8 @@ For the block stacks (and mouse art generated after running),

![Example Project](../js/js-export/samples/mode-up-down.png)

[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1725884337271676&run=True)

the following code is generated:

```
Expand Down