open-index/open-npm huggingface dataset:
npm package: @libraz/libsonare
Description: Audio analysis library for music information retrieval
Author: libraz
Latest version: 1.0.2

# libsonare

[![CI](https://img.shields.io/github/actions/workflow/status/libraz/libsonare/ci.yml?branch=main&label=CI)](https://github.com/libraz/libsonare/actions)
[![npm](https://img.shields.io/npm/v/@libraz/libsonare)](https://www.npmjs.com/package/@libraz/libsonare)
[![PyPI](https://img.shields.io/pypi/v/libsonare)](https://pypi.org/project/libsonare/)
[![License](https://img.shields.io/github/license/libraz/libsonare)](https://github.com/libraz/libsonare/blob/main/LICENSE)

Fast, dependency-free audio analysis library for browser and Node.js via WebAssembly. A librosa-like API for music information retrieval -- **tens of times faster** than Python.

## Installation

```bash
npm install @libraz/libsonare
```

## Usage

```typescript
import { init, detectBpm, detectKey, analyze, Audio } from '@libraz/libsonare';

await init();

// Function API
const bpm = detectBpm(samples, sampleRate);
const key = detectKey(samples, sampleRate);
const result = analyze(samples, sampleRate);
console.log(`BPM: ${result.bpm}, Key: ${result.key.name}`);

// Audio class API
const audio = Audio.fromBuffer(samples, sampleRate);
console.log(`BPM: ${audio.detectBpm()}`);
console.log(`Key: ${audio.detectKey().name}`);
```

### Browser (CDN)

```html
<script type="module">
  import { init, analyze } from 'https://esm.sh/@libraz/libsonare';

  await init();
  // ... use with Web Audio API
</script>
```

### Bundlers (Vite, webpack, Next.js, etc.)

If your bundler doesn't automatically resolve the `.wasm` file, specify its path:

```typescript
import wasmUrl from '@libraz/libsonare/wasm?url'; // Vite
import { init } from '@libraz/libsonare';

await init({ wasmPath: wasmUrl });
```

### Real-time Streaming

```typescript
import { init, StreamAnalyzer } from '@libraz/libsonare';

await init();

const analyzer = new StreamAnalyzer({ sampleRate: 44100 });

// In audio processing callback
analyzer.process(audioChunk);

const stats = analyzer.stats();
console.log(`BPM: ${stats.estimate.bpm}, Key: ${stats.estimate.key}`);
```

## Features

- **Detection**: BPM, key, beats, onsets, chords, sections
- **Effects**: HPSS, time stretch, pitch shift, normalize, trim
- **Features**: STFT, mel spectrogram, MFCC, chroma, CQT/VQT, spectral features
- **Pitch**: YIN, pYIN algorithms
- **Streaming**: Real-time analysis with progressive estimates
- **Conversions**: Hz/mel/MIDI/note, frames/time, resample

## Also available

```bash
pip install libsonare  # Python bindings with CLI
```

## License

[Apache License 2.0](https://github.com/libraz/libsonare/blob/main/LICENSE)
npm package: @libraz/mejiro-react
Description: React components for mejiro vertical text rendering
Author: libraz
Latest version: 0.3.0

# @libraz/mejiro-react

[![npm version](https://img.shields.io/npm/v/@libraz/mejiro-react.svg)](https://www.npmjs.com/package/@libraz/mejiro-react)
[![license](https://img.shields.io/npm/l/@libraz/mejiro-react.svg)](https://github.com/libraz/mejiro/blob/main/LICENSE)

React components and hooks for [mejiro](https://www.npmjs.com/package/@libraz/mejiro) vertical text rendering.

> **Experimental** — API may change in future releases.

## Install

```bash
npm install @libraz/mejiro @libraz/mejiro-react
```

Peer dependency: `react >= 18`

## Quick Start

```tsx
import { DEFAULT_HEADING_STYLES, MejiroBook } from '@libraz/mejiro/book';
import { parseEpub } from '@libraz/mejiro/epub';
import { MejiroPageView } from '@libraz/mejiro-react';
import '@libraz/mejiro/render/mejiro.css';

const book = new MejiroBook({
  fontFamily: '"Noto Serif JP"',
  fontSize: 16,
  lineSpacing: 1.8,
  headingStyles: DEFAULT_HEADING_STYLES,
});
book.computePageSize(containerEl);

const epub = await parseEpub(buffer);
const layout = await book.layoutChapter(epub.chapters[0]);
const spread = layout.getSpread(0);

<MejiroPageView result={spread.right} fontFamily='"Noto Serif JP"' lineSpacing={1.8} />
```

## Components

### `MejiroPageView` (Recommended)

Renders a `PageResult` from `ChapterLayout`. Automatically switches between CSS `vertical-rl` and slot-based rendering when images are present.

| Prop | Type | Description |
|------|------|-------------|
| `result` | `PageResult` | Required. Page result from `ChapterLayout`. |
| `fontFamily` | `string` | CSS font family (used in slot-based mode). |
| `lineSpacing` | `number` | Line spacing multiplier (used in slot-based mode). |
| `slotMode` | `boolean` | Force slot-based rendering (set when layout has images). |
| `className` | `string` | Additional CSS class name. |
| `style` | `CSSProperties` | Additional inline styles. |

### `MejiroPage` (Low-Level)

Renders a `RenderPage` using CSS `writing-mode: vertical-rl`. For use with the lower-level `buildRenderPage()` API.

## Hooks

### `useImageOverlay`

Manages a draggable/resizable image overlay with automatic text reflow.

```tsx
import { useImageOverlay } from '@libraz/mejiro-react';

const { imageRect, hasImage, toggleImage, onOverlayPointerDown, onResizePointerDown } =
  useImageOverlay(layout, spreadIdx, (spread) => setSpread(spread));
```

| Parameter | Type | Description |
|-----------|------|-------------|
| `layout` | `ChapterLayout \| null` | Current chapter layout. |
| `spreadIdx` | `number` | Current spread index. |
| `onUpdate` | `(spread: SpreadResult) => void` | Called after every reflow. |
| `options?` | `UseImageOverlayOptions` | Default dimensions, position, and margin. |

Returns `{ imageRect, hasImage, toggleImage, onOverlayPointerDown, onResizePointerDown }`.

## CSS

```ts
import '@libraz/mejiro/render/mejiro.css';
```

## License

[Apache License 2.0](https://github.com/libraz/mejiro/blob/main/LICENSE)
npm package: @libraz/mejiro-vue
Description: Vue components for mejiro vertical text rendering
Author: libraz
Latest version: 0.3.0

# @libraz/mejiro-vue

[![npm version](https://img.shields.io/npm/v/@libraz/mejiro-vue.svg)](https://www.npmjs.com/package/@libraz/mejiro-vue)
[![license](https://img.shields.io/npm/l/@libraz/mejiro-vue.svg)](https://github.com/libraz/mejiro/blob/main/LICENSE)

Vue components and composables for [mejiro](https://www.npmjs.com/package/@libraz/mejiro) vertical text rendering.

> **Experimental** — API may change in future releases.

## Install

```bash
npm install @libraz/mejiro @libraz/mejiro-vue
```

Peer dependency: `vue >= 3.3`

## Quick Start

```vue
<script setup lang="ts">
import { DEFAULT_HEADING_STYLES, MejiroBook } from '@libraz/mejiro/book';
import { parseEpub } from '@libraz/mejiro/epub';
import { MejiroPageView } from '@libraz/mejiro-vue';
import '@libraz/mejiro/render/mejiro.css';

const book = new MejiroBook({
  fontFamily: '"Noto Serif JP"',
  fontSize: 16,
  lineSpacing: 1.8,
  headingStyles: DEFAULT_HEADING_STYLES,
});
book.computePageSize(containerEl);

const epub = await parseEpub(buffer);
const layout = await book.layoutChapter(epub.chapters[0]);
const spread = layout.getSpread(0);
</script>

<template>
  <MejiroPageView :result="spread.right" fontFamily="'Noto Serif JP'" :lineSpacing="1.8" />
</template>
```

## Components

### `MejiroPageView` (Recommended)

Renders a `PageResult` from `ChapterLayout`. Automatically switches between CSS `vertical-rl` and slot-based rendering when images are present.

| Prop | Type | Description |
|------|------|-------------|
| `result` | `PageResult` | Required. Page result from `ChapterLayout`. |
| `fontFamily` | `string` | CSS font family (used in slot-based mode). |
| `lineSpacing` | `number` | Line spacing multiplier (used in slot-based mode). |
| `slotMode` | `boolean` | Force slot-based rendering (set when layout has images). |

### `MejiroPage` (Low-Level)

Renders a `RenderPage` using CSS `writing-mode: vertical-rl`. For use with the lower-level `buildRenderPage()` API.

## Composables

### `useImageOverlay`

Manages a draggable/resizable image overlay with automatic text reflow.

```ts
import { useImageOverlay } from '@libraz/mejiro-vue';

const { imageRect, hasImage, toggleImage, onOverlayPointerDown, onResizePointerDown } =
  useImageOverlay(layout, spreadIdx, (spread) => { spreadRef.value = spread; });
```

| Parameter | Type | Description |
|-----------|------|-------------|
| `layout` | `Ref<ChapterLayout \| null>` | Current chapter layout ref. |
| `spreadIdx` | `Ref<number>` | Current spread index ref. |
| `onUpdate` | `(spread: SpreadResult) => void` | Called after every reflow. |
| `options?` | `UseImageOverlayOptions` | Default dimensions, position, and margin. |

Returns `{ imageRect, hasImage, toggleImage, onOverlayPointerDown, onResizePointerDown }` (values are Vue refs or functions).

## CSS

```ts
import '@libraz/mejiro/render/mejiro.css';
```

## License

[Apache License 2.0](https://github.com/libraz/mejiro/blob/main/LICENSE)