Skip to main content

Crate nbslim

Crate nbslim 

Source
Expand description

§NBSlim – Geometric compression algorithms for 2D point sets

This crate implements SIA, SIATEC, COSIATEC, and RecurSIA – algorithms that discover translational equivalence classes (TECs) in planar point sets. It is designed primarily for compressing Note Block Studio (.nbs) music files but works on any set of points in the plane.

§Algorithms

  • SIA – finds all maximal translatable patterns from a point set.
  • SIATEC – builds translational equivalence classes from SIA results.
  • COSIATEC – greedy lossless compression: repeatedly extracts the best TEC and removes its covered points.
  • RecurSIA – recursive version of COSIATEC that compresses patterns of each TEC to capture nested repetitions.

§Examples

Basic compression:

use nbslim::cosiatec_compress;

let points = vec![(0, 100), (1, 200), (2, 100), (3, 200)];
let tecs = cosiatec_compress(&points, true, true);
assert!(tecs.len() > 0);

Modules§

utils
Utility functions for converting between note events and points, merging TECs, computing compression statistics, and reconstructing original data.

Structs§

TranslationalEquivalence
A translational equivalence class (TEC) consisting of a pattern (a set of points) and a set of non‑zero translation vectors that map the pattern onto other occurrences within the same dataset.

Functions§

build_tecs_from_mtps
Builds translational equivalence classes (TECs) for every maximal translatable pattern (MTP) found in the dataset by the SIA algorithm.
build_tecs_from_mtps_sweepline
Builds translational equivalences (TECs) using sweepline both for MTP discovery and exact matching.
cosiatec_compress
COSIATEC: a greedy, iterative compression algorithm based on translational equivalence classes (TECs).
find_mtps
Finds all maximal translatable patterns (MTPs) in a 2‑D point set using the SIA algorithm.
recursive_cosiatec_compress
RECURSIA (Recursive SIA) applied to the COSIATEC compression algorithm.