Skip to content

Commit 9b536c9

Browse files
committed
ArtworkAndEyeDropper
1 parent 1f92f04 commit 9b536c9

File tree

11 files changed

+532
-143
lines changed

11 files changed

+532
-143
lines changed

documentation/README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,10 +654,26 @@ try to make a corresponding change in the matrix.
654654
Note: You can construct a matrix from a chuck of blocks by including
655655
the chunk in the clamp of the _Pitch-time Marix_ block.
656656

657+
658+
![LEGO Bricks](./legobricks_block.svg "LEGO Bricks block")
659+
660+
The _LEGO Bricks_ widget provides an innovative way to create music by analyzing colored LEGO brick patterns from images or live webcam feeds. This widget transforms visual art into musical compositions by detecting color changes and converting them into musical notes.
661+
662+
The widget features an interactive interface where users can upload images of LEGO brick arrangements or use their webcam to capture live constructions. An eye dropper tool allows users to select the background color (such as green baseplates, white surfaces, or any colored background), ensuring accurate color detection regardless of the surface the LEGO bricks are placed on.
663+
664+
As the widget scans the image with vertical lines, it detects different colored LEGO bricks and maps them to corresponding musical pitches. The scanning speed and column spacing can be adjusted for precise timing control. Non-background colors trigger musical notes, while areas matching the selected background color remain silent, creating natural rests in the composition.
665+
666+
![LEGO Bricks Widget](./legobricks_widget.svg "LEGO Bricks Widget")
667+
668+
The _LEGO Bricks_ widget supports multiple output formats: real-time audio playback during scanning, export as Music Blocks action blocks for further editing, and downloadable visualizations of the detected color patterns. This makes it an excellent tool for combining physical construction play with musical creativity, allowing users to literally build their melodies with LEGO bricks.
669+
670+
![LEGO Bricks Demo](./legobricks_demo.svg "LEGO Bricks Widget Demo")
671+
672+
If you want to read more about the LEGO Bricks widget, including detailed usage instructions and educational applications, see the [Music Blocks Programming Guide](http://github.com/sugarlabs/musicblocks/tree/master/guide/README.md#427-lego-bricks-widget).
673+
657674
More details about all of the widgets are available in the
658675
[Music Blocks Programming Guide](http://github.com/sugarlabs/musicblocks/tree/master/guide/README.md).
659676

660-
661677
## 8. Stats
662678

663679

documentation/legobricks_block.svg

Lines changed: 9 additions & 0 deletions
Loading

documentation/legobricks_demo.svg

Lines changed: 9 additions & 0 deletions
Loading

documentation/legobricks_widget.svg

Lines changed: 9 additions & 0 deletions
Loading

guide/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ This guide details the many musical features of the language.
7272
4. [What is a Tuplet?](#424-what-is-a-tuplet)
7373
5. [Using Individual Notes](#425-using-individual-notes)
7474
6. [Using a Scale of Pitches](#426-using-a-scale-of-pitches)
75+
7. [LEGO Bricks Widget](#427-lego-bricks-widget)
7576
3. [Generating Rhythms (or How to Make a Drum Machine)](#43-generating-rhythms)
7677
4. [Musical Modes](#44-musical-modes)
7778
5. [Changing Meter](#45-meters)
@@ -1837,6 +1838,73 @@ inside the *Repeat*, working our way down to `Sol` in `Octave
18371838
4`. Another detail to note is the use of the *Mode length* block.
18381839
[RUN LIVE](https://musicblocks.sugarlabs.org/index.html?id=1735824170382853&run=True)
18391840

1841+
#### <a name="LEGO-BRICKS">4.2.7 LEGO Bricks Widget</a>
1842+
1843+
![LEGO Bricks](./legobricks_block.svg "LEGO Bricks block")
1844+
1845+
The *LEGO Bricks* widget represents a groundbreaking approach to music composition that bridges the physical and digital worlds. This innovative tool transforms tangible LEGO brick constructions into dynamic musical compositions through advanced computer vision and color detection algorithms.
1846+
1847+
![LEGO Bricks Widget](./legobricks_widget.svg "LEGO Bricks Widget Interface")
1848+
1849+
The widget operates by analyzing colored LEGO brick arrangements from uploaded images or live webcam feeds. Users can upload photos of their LEGO creations or use their device's camera to capture constructions in real-time. The widget features an intelligent color detection system that can adapt to different backgrounds and lighting conditions.
1850+
1851+
![LEGO Bricks Demo](./legobricks_demo.svg "LEGO Bricks Widget Demo Example")
1852+
1853+
**Key Features:**
1854+
1855+
- **Multiple Input Sources**: Upload images of LEGO brick patterns or use webcam for live construction analysis
1856+
- **Smart Background Detection**: Eye dropper tool allows selection of background color (green baseplates, white surfaces, etc.) for accurate color detection
1857+
- **Real-time Color Analysis**: As the widget scans across the image with vertical lines, it identifies different colored bricks and maps them to musical pitches
1858+
- **Customizable Scanning**: Adjustable scanning speed and column spacing for precise timing control
1859+
- **Interactive Color Selection**: Live preview tooltip shows detected colors while hovering over the image
1860+
1861+
**How It Works:**
1862+
1863+
The widget scans the uploaded image or webcam feed using vertical scanning lines that move from left to right. Each vertical line represents a moment in time, while the vertical position corresponds to different musical pitches. When the scanner encounters a LEGO brick that differs from the selected background color, it triggers a musical note corresponding to that color and vertical position.
1864+
1865+
**Musical Output:**
1866+
1867+
- **Real-time Audio Playback**: Hear your LEGO creation as music while the scanning progresses
1868+
- **Action Block Export**: Generate Music Blocks code that can be further edited and incorporated into larger compositions
1869+
- **Visual Feedback**: Color detection visualization shows which areas of the image are being interpreted as musical notes
1870+
- **Downloadable Results**: Save both the generated music blocks and visual analysis for future use
1871+
1872+
**Educational Value:**
1873+
1874+
The LEGO Bricks widget combines STEM learning with creative expression, teaching concepts of pattern recognition, color theory, rhythm and timing, and creative coding. It bridges physical construction with digital programming concepts, making it particularly effective for introducing younger learners to music composition while leveraging their natural affinity for construction play.
1875+
1876+
**Advanced Features:**
1877+
1878+
**Input Methods and Flexibility:**
1879+
- Image upload support for various formats (JPEG, PNG, WebP)
1880+
- Live webcam integration for real-time analysis
1881+
- Batch processing for creating longer musical compositions
1882+
1883+
**Color Detection System:**
1884+
- Adaptive color calibration for various lighting conditions
1885+
- Color family recognition to prevent minor shade variations
1886+
- User-configurable tolerance settings for different environments
1887+
1888+
**Scanning Technology:**
1889+
- Precise vertical line scanning with systematic left-to-right movement
1890+
- Height-to-pitch conversion for intuitive spatial-to-musical relationships
1891+
- Horizontal spacing check for natural rhythmic pattern generation
1892+
1893+
**Educational Applications:**
1894+
1895+
**Musical Pedagogy:**
1896+
- Pattern recognition skills through visual-spatial construction
1897+
- Rhythm and timing concepts via spatial arrangement
1898+
- Pitch relationships through vertical construction patterns
1899+
- Composition techniques using systematic building approaches
1900+
1901+
**Creative Development:**
1902+
- Synesthetic learning connecting visual, spatial, and auditory perception
1903+
- Problem-solving skills for achieving specific musical outcomes
1904+
- Collaborative creativity in group construction projects
1905+
1906+
This widget exemplifies Music Blocks' philosophy of making music programming accessible and engaging by connecting familiar physical activities with abstract musical concepts. It serves as an ideal introduction to musical notations for a blind or a visually challenged individual. We can make it a lot more better in future and make many more activities with it LegoBlocks.
1907+
18401908
### <a name="rhythms">4.3 Generating Rhythms</a>
18411909

18421910
The *Rhythm Maker* block is used to launch a widget similar to the

guide/legobricks_block.svg

Lines changed: 9 additions & 0 deletions
Loading

guide/legobricks_demo.svg

Lines changed: 9 additions & 0 deletions
Loading

guide/legobricks_widget.svg

Lines changed: 9 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)