|
| 1 | +--- |
| 2 | +title: "DMP '25 Week 06 Update by Anvita Prasad" |
| 3 | +excerpt: "Improve Synth and Sample Feature for Music Blocks" |
| 4 | +category: "DEVELOPER NEWS" |
| 5 | +date: "2025-07-13" |
| 6 | +slug: "2025-07-13-DMP-25-AnvitaPrasad-week06" |
| 7 | +author: "@/constants/MarkdownFiles/authors/anvita-prasad.md" |
| 8 | +tags: "dmp25,sugarlabs,week06,AnvitaPrasad,midterm" |
| 9 | +image: "assets/Images/c4gt_DMP.png" |
| 10 | +--- |
| 11 | + |
| 12 | +<!-- markdownlint-disable --> |
| 13 | + |
| 14 | +# Week 06 Progress Report by Anvita Prasad |
| 15 | + |
| 16 | +**Project:** [Music Blocks - Improve Synth and Sample Features](https://github.com/sugarlabs/musicblocks/issues/4539) |
| 17 | +**Mentors:** [Walter Bender](https://github.com/walterbender) |
| 18 | +**Assisting Mentors:** [Devin Ulibarri](https://github.com/pikurasa) |
| 19 | +**Reporting Period:** 2025-07-07 - 2025-07-13 |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Goals for This Week |
| 24 | +- **Goal 1:** Implement manual cent adjustment functionality in the sampler widget |
| 25 | +- **Goal 2:** Ensure cent adjustments persist when saving samples |
| 26 | +- **Goal 3:** Research methods for manual cent adjustment implementation |
| 27 | +- **Goal 4:** Collect SVG icons for the set instrument widget |
| 28 | +- **Goal 5:** Design basic categorization system for samples |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## This Week's Achievements |
| 33 | + |
| 34 | +1. **Cent Adjustment Persistence Implementation** |
| 35 | + - Extended the CUSTOMSAMPLES array to include cent adjustment values |
| 36 | + - Modified _addSample function to maintain backward compatibility |
| 37 | + - Updated __save function to include cent adjustment in block properties |
| 38 | + - Enhanced _updateBlocks to display cent adjustments in block text (e.g., "C4 +10¢") |
| 39 | + |
| 40 | +2. **Playback Rate Calculation System** |
| 41 | + - Implemented the mathematical formula for converting cents to playback rate |
| 42 | + - Applied consistent calculation throughout the codebase (playbackRate = Math.pow(2, cents/1200)) |
| 43 | + - Ensured accurate pitch modification across all sample playback scenarios |
| 44 | + |
| 45 | +3. **Synth Integration** |
| 46 | + - Modified _createSampleSynth function to store cent adjustments with samples |
| 47 | + - Updated trigger function to apply adjustments to playback rate during sample playback |
| 48 | + - Created framework for real-time pitch modification during performance |
| 49 | + |
| 50 | +4. **Instrument Organization and Visualization** |
| 51 | + - Collected SVG icons for each instrument and instrument family |
| 52 | + - Designed a hierarchical structure to better organize the set instruments widget |
| 53 | + - Created a more intuitive categorization system for instrument selection |
| 54 | + - Improved visual navigation through instrument families |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +## Challenges & How I Overcame Them |
| 59 | + |
| 60 | +- **Challenge:** Persisting Cent Adjustment Information |
| 61 | + **Solution:** In the previous week, I had implemented cent adjustments by modifying the playback rate in real-time, but this information wasn't being stored with the sample. This meant that when a user saved a sample after making cent adjustments, the adjustments were lost, creating inconsistency in musical compositions. I researched two main approaches: storing notes as floating-point MIDI values (e.g., 60.1 for C4+10¢) or storing integer MIDI notes and cent adjustments separately. I chose the second approach for better compatibility with Music Blocks' existing codebase, clearer data representation, and easier UI integration. I'm still testing this implementation to ensure it works correctly across all use cases. |
| 62 | + |
| 63 | +- **Challenge:** Modifying the Sample Data Structure |
| 64 | + **Solution:** I carefully extended the CUSTOMSAMPLES array to include the cent adjustment value while ensuring backward compatibility. This required precise modifications to several core functions that interact with the sample data structure. |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## Key Learnings |
| 69 | +- Audio Processing Fundamentals: Deepened understanding of how cent adjustments affect pitch perception and the mathematical relationship between cents and playback rate. |
| 70 | +- Data Persistence Strategies: Learned different approaches to storing and retrieving fine-grained musical parameters, and the trade-offs between integrated vs. separate storage models |
| 71 | +- DOM Manipulation for Audio UI: Gained experience creating responsive audio controls that provide visual feedback while manipulating sound parameters in real-time |
| 72 | +- Code Refactoring Best Practices: Developed skills in modifying existing functionality while maintaining backward compatibility, especially in a complex music programming environment |
| 73 | +- Tone.js Audio API: Enhanced understanding of Tone.js's Sampler implementation and how to manipulate playback parameters like playback rate for pitch adjustments |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +## Midterm Evaluation Summary (Weeks 01–06) |
| 78 | + |
| 79 | +Over the past six weeks, I've made significant progress on improving Music Blocks' synth and sample features, focusing on enhancing the tuning system and implementing micro-pitch adjustments. I've successfully completed the development of a comprehensive dual-mode tuner system that provides precise pitch feedback and visualization. Additionally, I've implemented a manual cent adjustment feature that allows for microtonality exploration and fine-tuning of samples. These enhancements significantly expand Music Blocks' capabilities for musical education, enabling students to explore pitch relationships beyond standard Western tuning systems and providing educators with powerful tools for teaching advanced musical concepts. |
| 80 | + |
| 81 | +### Technical Achievements |
| 82 | + |
| 83 | +1. **Audio Foundation Improvements** |
| 84 | + - Updated Tone.js library from version 15.0.4 to 15.1.22 |
| 85 | + - Integrated YIN algorithm for accurate pitch detection |
| 86 | + - Implemented low-pass filtering to handle high-frequency noise |
| 87 | + - Enhanced pitch detection accuracy using parabolic interpolation |
| 88 | + |
| 89 | +2. **Tuner System Development** |
| 90 | + - Created comprehensive dual-mode tuner interface: |
| 91 | + - Chromatic mode that automatically finds closest pitch |
| 92 | + - Target pitch mode with fixed reference point |
| 93 | + - Implemented 11-segment visualization system with center-outward lighting |
| 94 | + - Added clear visual feedback for cent deviation |
| 95 | + - Designed mode-specific icons and toggle interface |
| 96 | + |
| 97 | +3. **Cent Adjustment System** |
| 98 | + - Evolved from initial pie menu design to more efficient slider interface |
| 99 | + - Implemented ±50 cents range adjustment capability |
| 100 | + - Created framework for real-time pitch modification |
| 101 | + - Developed system to store and apply cent adjustments to samples |
| 102 | + - Extended data structures to maintain cent adjustment information |
| 103 | + |
| 104 | +4. **Integration and Testing** |
| 105 | + - Conducted extensive testing with various audio sources |
| 106 | + - Created test suite for tuner accuracy verification |
| 107 | + - Optimized signal processing for better performance |
| 108 | + - Ensured backward compatibility throughout implementation |
| 109 | + |
| 110 | +### Educational and Creative Impact |
| 111 | + |
| 112 | +These improvements significantly enhance Music Blocks' capabilities for musical education and exploration: |
| 113 | + |
| 114 | +- **Microtonality Access**: Students can now explore pitches between standard Western notes, opening doors to world music traditions and experimental composition |
| 115 | +- **Improved Accuracy**: The enhanced tuner provides precise feedback for instrument tuning and vocal training |
| 116 | +- **Educational Value**: Visual feedback systems help students understand pitch relationships and develop better ear training |
| 117 | +- **Creative Possibilities**: Cent adjustments enable more expressive performances and composition with subtle pitch variations |
| 118 | + |
| 119 | +### Final Thoughts |
| 120 | + |
| 121 | +The first half of this project has established a solid foundation for Music Blocks' enhanced audio capabilities. The dual-mode tuner and cent adjustment systems provide both technical accuracy and user-friendly interfaces for students and educators. These features have significantly expanded Music Blocks' capacity for musical exploration beyond standard Western tuning. Moving forward, I'll focus on sample organization and multiple sample functionality to further enhance the expressiveness and educational value of the platform. |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +## Next Week's Roadmap |
| 126 | +- Implement the basic categorization system for samples |
| 127 | +- Process free/open samples from identified sources |
| 128 | +- Work on handling multiple samples |
| 129 | +- Test the manual cent adjustment feature and finalise the approach |
| 130 | +- Write Week 07 blog post summarizing progress and learnings |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +## Resources & References |
| 135 | +- **Audio Processing:** [Web Audio API Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API) |
| 136 | +- **Cent Calculation:** [Cents to Frequency Ratio Calculator](https://www.sengpielaudio.com/calculator-centsratio.htm) |
| 137 | +- **Musical Tuning:** [Musical Acoustics - Cents and Frequency Ratios](https://newt.phys.unsw.edu.au/jw/notes.html) |
| 138 | +- **Tone.js Documentation:** [Tone.js Sampler](https://tonejs.github.io/docs/14.7.77/Sampler) |
| 139 | +- **Audio Sample Processing:** [Microtonality in Digital Audio Workstations](https://www.researchgate.net/publication/327567188_Microtonality_and_the_DAW_A_Design_Study) |
| 140 | + |
| 141 | +--- |
| 142 | + |
| 143 | +## Acknowledgments |
| 144 | +Thank you to my mentors, the Sugar Labs community, and fellow contributors for ongoing support. |
| 145 | + |
| 146 | +--- |
0 commit comments