232 lines
13 KiB
Markdown
232 lines
13 KiB
Markdown
# BeatHound Software Guide
|
|
|
|
This guide explains how to use BeatHound and how the software is put together. It uses short sentences and explains technical words when they first appear.
|
|
|
|
## 1. What BeatHound does
|
|
|
|
BeatHound is a beat-making tool that runs in a web browser. It shows one circular loop. You place sound points on the loop, move them, and play the pattern.
|
|
|
|
The instrument menu has Drums, Percussion, Bass, Keys, Strings, Winds, and Synth. It includes Kick, Snare, Hi-hat, Toms, Cymbals, Clap, Shaker, Cowbell, Woodblock, Bongos, Bass, Piano, Organ, Strings, Winds, and Synth. BeatHound creates these sounds in your browser; it does not load audio recordings.
|
|
|
|
The app needs no account or backend server. Your current loop lives in the open page. It is not saved when you refresh or close the page.
|
|
|
|
## 2. Use the beat maker
|
|
|
|
### Start a pattern
|
|
|
|
1. Open the Dance template menu near the top of the page.
|
|
2. Choose a template, or choose **Empty** to clear the loop.
|
|
3. Choose a category in the bottom toolbar, such as **Drums** or **Keys**.
|
|
4. Press the **+** button beside the category menu to see its instruments.
|
|
5. Choose an instrument. A point for it appears at an available place on the loop.
|
|
|
|
Adding the same instrument more than once adds more points of that instrument.
|
|
|
|
When you select a point for an instrument with pitch support, a pitch slider appears in the toolbar. It changes the selected point by up to two octaves in either direction. The note name follows that instrument's base note. Instruments such as Hi-hat, Snare, and Shaker do not have pitch controls.
|
|
|
|
### Move and select sound points
|
|
|
|
- Drag a point around its circle to change when it plays.
|
|
- Click or tap a point to select it. Its category ring is selected too.
|
|
- You can also focus a point with the keyboard. Use the arrow keys to move it. Hold **Shift** with an arrow key to move by a larger step.
|
|
- Instruments in the same category share one ring. Each ring has an uppercase letter, from **A** to **G**. Each beat has its own lowercase letter inside the ring. For example, **A-a** means beat `a` in category `A`.
|
|
- The legend below the loop connects category letters and beat letters to their names. Press and hold a category in the legend to rename it for the current page session.
|
|
- Click or tap a ring or use the category-ring selector above the loop to focus a category.
|
|
|
|
Use the trash button beside the loop to remove sound. If a point is selected, the button removes only that beat. If a category ring is selected and no point is selected, it removes every beat in that category.
|
|
|
|
### Change the loop and speed
|
|
|
|
- **Time signature** sets how many beats are in the loop. BeatHound offers 2/4 through 8/4.
|
|
- **BPM** means beats per minute. Use the tempo menu to choose a speed from 60 to 180 BPM. The starting speed is 112 BPM.
|
|
- **Play** starts the loop. Press **Pause** to stop it. Starting playback needs a sound in the loop.
|
|
|
|
The usual loop is 4/4. Each beat has four main steps, so a 4/4 loop has 16 main steps. The circular play marker shows where playback is.
|
|
|
|
Dragging allows small timing changes between main steps. The sound plays at the closest supported timing point. Keyboard arrow keys make small changes; **Shift** plus an arrow moves by one full main step.
|
|
|
|
If you shorten the loop, sound points outside the new loop length are hidden. They can appear again if you make the loop longer later.
|
|
|
|
### Included templates
|
|
|
|
Templates replace the current pattern and set its speed and time signature.
|
|
|
|
| Template | Loop | Speed | Pattern |
|
|
| --- | --- | ---: | --- |
|
|
| Empty | 4/4 | 112 BPM | No sound points |
|
|
| Bachata | 4/4 | 120 BPM | Kick on beats 1, 2, 3, and 4 |
|
|
| Salsa | 4/4 | 180 BPM | Kick on beats 1, 2, and 3 |
|
|
| Lindy Hop | 8/4 | 120 BPM | Kick on beats 1 through 8 |
|
|
|
|
## 3. Sound and browser behavior
|
|
|
|
BeatHound uses the browser's **Web Audio API** to make sound. The Kick is made from low electronic tones. The Hi-hat is made from short filtered noise.
|
|
|
|
Browsers often block sound until the user interacts with the page. Press **Play** to allow the browser to start audio. If audio cannot start, BeatHound shows an error below the loop. Check the browser's audio settings and try again.
|
|
|
|
The app makes playback ticks with a browser timer. At each tick it checks whether a sound point should play. The exact timing can depend on the browser and the device.
|
|
|
|
The page layout adapts to different screen sizes. The project includes a web app manifest, icons, and Capacitor projects for Android and iOS. It does not include code for saving patterns or working offline. See the [native build guide](native-builds.md) for mobile build requirements.
|
|
|
|
## 4. Run the project on your computer
|
|
|
|
### Requirements
|
|
|
|
- A recent Node.js release with npm.
|
|
- A modern browser with Web Audio support to use the app.
|
|
|
|
### Install and run
|
|
|
|
From the project folder, run:
|
|
|
|
```sh
|
|
npm install
|
|
npm run dev
|
|
```
|
|
|
|
Vite prints a local web address. Open that address in your browser. The dev server listens on all network interfaces, so it may also be reachable from another device on your local network.
|
|
|
|
### Checks and production build
|
|
|
|
```sh
|
|
npm run lint
|
|
npm run build
|
|
npm test
|
|
```
|
|
|
|
- `npm run lint` checks the source code with ESLint.
|
|
- `npm run build` checks TypeScript and creates the production files in `dist/`.
|
|
- `npm test` runs the tests with Vitest.
|
|
|
|
## 5. How the software is organized
|
|
|
|
BeatHound is a React and TypeScript app. Ionic React provides many of the buttons, popovers, and page elements. Vite runs the development server and builds the web app. Capacitor wraps that web app in Android and iOS projects.
|
|
|
|
The main path through the app is:
|
|
|
|
1. `index.html` provides the page shell and mobile and sharing metadata.
|
|
2. `src/main.tsx` loads Ionic styles and the app's styles, then starts React.
|
|
3. `src/App.tsx` keeps the shared studio state and chooses which view is open.
|
|
4. `src/views/StudioView.tsx` displays the beat maker. `src/views/AboutView.tsx` displays app information.
|
|
5. Components display the loop, header menu, and controls.
|
|
6. Hooks manage the loop state, sound colors, and playback.
|
|
7. Domain files define beat data and calculate loop positions.
|
|
8. Audio files create and play the sounds.
|
|
|
|
### Source folder guide
|
|
|
|
| Path | What it does |
|
|
| --- | --- |
|
|
| `src/App.tsx` | Holds shared studio state and selects the active view. |
|
|
| `src/main.tsx` | Starts React and loads Ionic and app styles. |
|
|
| `src/styles.css` | Defines the colors, layout, and responsive page styles. |
|
|
| `src/components/AppHeader.tsx` | Shows the brand and the top-right menu for switching views. |
|
|
| `src/views/StudioView.tsx` | Shows the beat-making studio. |
|
|
| `src/views/AboutView.tsx` | Shows the version, license, technologies, source repository, and issue tracker. |
|
|
| `src/views/viewTypes.ts` | Defines the names of the app's views. |
|
|
| `src/config/projectInfo.ts` | Keeps version and project links in one place for the About view. |
|
|
| `src/components/BeatLoopPanel.tsx` | Combines the circular loop, tempo, time signature, category rings, hint, legend, and delete button. |
|
|
| `src/components/CircularTimeline.tsx` | Draws category rings, labeled beat points, and the playback marker. It handles pointer and keyboard movement. |
|
|
| `src/components/CategoryRingSelector.tsx` | Selects one of the active category rings. |
|
|
| `src/components/CategoryLegend.tsx` | Maps category and beat letters to instrument names; a long press opens the rename dialog. |
|
|
| `src/components/TransportBar.tsx` | Shows Play/Pause, the instrument menu, and pitch control. |
|
|
| `src/components/InstrumentSelector.tsx` | Selects an instrument category and shows its choices from the plus button. |
|
|
| `src/components/PitchControl.tsx` | Changes pitch on a selected point when its instrument supports pitch. |
|
|
| `src/components/BeatTemplateSelector.tsx` | Shows the template menu. |
|
|
| `src/components/TempoControl.tsx` | Changes the speed. |
|
|
| `src/components/TimeSignatureSelector.tsx` | Changes the number of beats in the loop. |
|
|
| `src/components/SoundRingSelector.tsx` | Compatibility export for the category ring selector. |
|
|
| `src/components/BeatSelectionHint.tsx` | Shows the selected category, beat letter, instrument, and position. |
|
|
| `src/hooks/useBeatStudio.ts` | Connects the sequencer and sound color palette. |
|
|
| `src/hooks/useBeatSequencer.ts` | Gives the interface actions for adding, moving, selecting, and removing points. |
|
|
| `src/hooks/useBeatPlayback.ts` | Starts and stops playback and moves the play marker. |
|
|
| `src/hooks/useSoundPalette.ts` | Gives each active category a color. |
|
|
| `src/hooks/useCategoryLabels.ts` | Stores custom legend names for the current page session. |
|
|
| `src/hooks/usePopoverDisclosure.ts` | Tracks whether an Ionic popover is open. |
|
|
| `src/domain/sequencer.ts` | Defines beat data, loop sizes, tempo limits, and timing helpers. |
|
|
| `src/domain/sequencerReducer.ts` | Applies changes to the sequencer state. |
|
|
| `src/domain/timeline.ts` | Converts between loop positions and points on the circle. |
|
|
| `src/domain/instruments.ts` | Lists instruments, categories, and pitch settings. |
|
|
| `src/domain/sounds.ts` | Re-exports older sound names for compatibility. |
|
|
| `src/domain/soundColors.ts` | Creates distinct colors for active categories. |
|
|
| `src/domain/beatTemplates.ts` | Defines the included templates. |
|
|
| `src/audio/AudioEngine.ts` | Starts the browser audio context and sends sounds to it. |
|
|
| `src/audio/instruments.ts` | Creates the synthesized instrument sounds. |
|
|
| `src/audio/soundVoices.ts` | Connects each instrument ID to its sound-making function. |
|
|
| `capacitor.config.ts` | Sets the app ID, app name, and native web asset folder. |
|
|
| `android/` and `ios/` | Capacitor project files for native mobile builds. |
|
|
| `downloads/` | Holds the Android/e/OS debug APK available from this repository. |
|
|
| `src/sequencer.test.ts` | Tests timing, loop geometry, state changes, colors, and templates. |
|
|
| `public/` | Holds icons, logos, and the web app manifest. |
|
|
|
|
`src/sequencer.ts` is a small export file. It re-exports domain helpers and templates for use by tests and other files.
|
|
|
|
### Project setup files
|
|
|
|
| Path | What it does |
|
|
| --- | --- |
|
|
| `package.json` | Lists the packages used by the project and the npm commands. |
|
|
| `package-lock.json` | Records exact package versions for repeatable installs. |
|
|
| `capacitor.config.ts` | Sets the native app ID, display name, and web build folder. |
|
|
| `vite.config.ts` | Turns on the React plugin and sets up Vitest. |
|
|
| `tsconfig.json` | Sets TypeScript rules. The project uses strict type checking. |
|
|
| `eslint.config.js` | Sets the code checks used by ESLint. |
|
|
| `.gitignore` | Keeps generated files such as `dist/` and `node_modules/` out of Git. |
|
|
| `public/manifest.webmanifest` | Gives the app a name, icons, colors, and home-screen display settings. |
|
|
| `src/ionicons.d.ts` | Tells TypeScript which Ionicons names this app uses. |
|
|
| `android/` and `ios/` | Capacitor native project files. |
|
|
| `downloads/` | Checked-in Android/e/OS debug APK. |
|
|
|
|
## 6. How loop data works
|
|
|
|
Each beat point has these values:
|
|
|
|
- `id`: a unique name for that point.
|
|
- `soundId`: the instrument type, such as `kick` or `hi-hat`.
|
|
- `letter`: its lowercase label inside the category ring. Labels are unique within a category.
|
|
- `step`: its position in the loop. Whole numbers are main steps. Fractions allow small timing changes.
|
|
- `pitchSemitones`: an optional pitch offset for instruments that support pitch.
|
|
|
|
The sequencer state also tracks the selected point, selected category ring, tempo, and beats per bar. `src/domain/sequencerReducer.ts` receives named actions and returns the next state. This keeps changes in one predictable place.
|
|
|
|
The loop size is four main steps per beat. For example, 4/4 has 16 main steps and 8/4 has 32. Playback checks four smaller timing points within each main step.
|
|
|
|
The loop is held in React state. There is no database, network API, or browser storage in this version.
|
|
|
|
## 7. Add another sound
|
|
|
|
To add an instrument, update these files:
|
|
|
|
1. Add its ID, label, category, and pitch support to `src/domain/instruments.ts`.
|
|
2. Add its ID to the correct category list in that file.
|
|
3. Write a function that uses `AudioContext` in `src/audio/instruments.ts`.
|
|
4. Add its instrument ID and function to `src/audio/soundVoices.ts`.
|
|
|
|
The toolbar menu reads its groups from the instrument catalog, and the color hook assigns a color when an instrument is added. The timeline uses the instrument ID, so it usually does not need an instrument-specific change.
|
|
|
|
## 8. Add another template
|
|
|
|
Add a template object to `BEAT_TEMPLATES` in `src/domain/beatTemplates.ts`. Include:
|
|
|
|
- A unique ID and a label.
|
|
- A short description.
|
|
- The number of beats per bar.
|
|
- A tempo from 60 to 180 BPM.
|
|
- Sound points whose steps fit inside that loop.
|
|
|
|
Also add the new ID to the `BeatTemplateId` type in that file. The menu reads its options from `BEAT_TEMPLATES`.
|
|
|
|
## 9. Tests and quality checks
|
|
|
|
The tests in `src/sequencer.test.ts` check the logic that can be tested without a browser. They check circular positions, fractional positions, tempo limits, state changes, colors, and templates.
|
|
|
|
Before sharing a change, run:
|
|
|
|
```sh
|
|
npm run lint
|
|
npm run build
|
|
npm test
|
|
```
|
|
|
|
If you change behavior, update or add a test for that behavior.
|