Logo BCDDLogo CSC
BCDDBehavioural Contract-Driven Design
version 1.0-beta
ITEN

Chapter 28 — A real case: the audio measurement kit

The previous chapters use a small example, built to introduce one form at a time. This chapter examines the description of a real system, an audio measurement kit, and the report that bcdd produces on it. It does not introduce new forms: each element refers back to the chapter in which it is described.

The system

The kit is added to a listening system made up of a source, an amplifier and the loudspeakers. The music signal, which in the files is called “programma” (programme), passes from the source to the kit's computer and from there to the amplifier. The computer is a Raspberry Pi 4 with an audio processing program, abbreviated AP in the files. The kit measures the acoustic response of the room and derives from it a correction for the music signal; during listening it detects the level sent to the loudspeakers.

AP works in three modes, Misure, Calcolo and Riproduzione (Measurement, Calculation and Playback), which are chosen from the AP window or from the phone. When moving from one mode to another, the user moves the cables by hand between the two inputs of the card that captures the signals, input L and input R.

The kit exists in two models, 1.a and 1.b; this chapter examines model 1.b, which uses two sound cards. The stream card carries the programme signal; the capture card receives the signals of the measurement microphone, of the level sensor and of the reference. For the level sensor there are two choices. The first is a direct box (DI in the files): a small device that takes the signal from the output terminals of the amplifier, to which the loudspeakers are connected, and carries it to the capture card. The second is the measurement microphone itself, which after the measurements is moved close to a loudspeaker. In the first choice the direct box is an optional part: without it the Loudness function of AP, which depends on the level sensor, cannot be used, while the rest of the kit works.

The description

The description consists of several files, each with a CSC or an entity (chapters 2 and 12). The CSCs describe the boundaries: for example Modalita, the choice of mode; Ricablaggio, the cables that the user moves between one mode and another; Morsetti, the output of the amplifier at the loudspeaker terminals. The entities describe the devices: the computer, the two cards, the microphone, the direct box, the cable that carries back the reference. The entity Kit1b describes the kit as a whole; the entity Impianto1b describes the kit together with the user's devices.

The direct box is an entity with one used boundary and one provided boundary (chapter 12):

-- The direct box performs the detection of the output level at the terminals of a passive loudspeaker.
-- The direct box used as reference in Misure is another function, Riferimento: not described here.
-- Postponed: connectors, attenuators, maximum levels, phantom or battery power supply.
-- Sources: system model, sections on the direct box; indications of the operator.

ENTITY DirectBox VERSION 0.1
  STATUS HYPOTHESIS
  PURPOSE "The direct box of the kit: it reads the signal at the terminals of a loudspeaker and carries it to the capture card as level sensor"
  USES   Morsetti
  OFFERS SegnaleLivello
  GUARANTEE di1 STATUS RATIFIED BY D-20: VERBAL "The output level of the DI is the level at the terminals minus the chosen attenuation: the attenuator is chosen according to the input that receives it (source: system model, section on the direct box; indication of the operator)"
                 VERIFY BY JUDGEMENT "the operator, who compares the level read with two positions of the attenuator"
  GUARANTEE di2 STATUS RATIFIED BY D-20: VERBAL "The DI outputs an essentially line-level signal, often balanced, and can also go into a line input (source: indication of the operator)"
                 VERIFY BY INSPECTION "the data sheet of the DI"
END

The file applies some conventions adopted throughout the description of the kit. The header comments indicate the sources of the facts and what the file does not describe; in the files shown here the sources are indicated in generic form. Each guarantee shows its own source in parentheses, inside the text in quotation marks. bcdd does not interpret that text (chapter 2): the sources are therefore meant for the reader and the approver.

The guarantees are approved one by one with the decision D-20, while the header remains STATUS HYPOTHESIS: in an entity the header is not approved, only the individual guarantees (chapter 12). The CSCs of the kit follow the same scheme: the guarantees have their own STATUS (chapter 7).

The connectors, attenuators, maximum levels and power supply of the direct box, cited in the third comment, are elements that whoever is at the boundary observes or uses, that is, concrete forms (chapter 25); the description of the kit does not contain them yet. The power supply can be phantom (supplied by the card through the cable) or battery.

The kit entity

The following extract shows the main lines of Kit1b.csc. The omitted lines are indicated with …; the line numbers of the report refer to the whole file.

ENTITY Kit1b VERSION 0.2
  STATUS HYPOTHESIS
  PURPOSE "The kit for the DSP passthrough on Raspberry Pi 4 with two cards: one carries the programme, the other captures microphone, level sensor and reference"
  OFFERS Modalita
  OFFERS Misura
  OFFERS LetturaLivello
  OFFERS Ricablaggio
  OFFERS RilevamentoLivello
  USES   Programma
  USES   IngressoAmplificatore
  COMPOSED OF
    computer  : Calcolatore1b
    flusso    : SchedaFlusso
    cattura   : SchedaCattura
    loop      : CavoLoop
  …
  GUARANTEE k4 STATUS RATIFIED BY D-20: VERBAL "The programme passes from input to output with at most 100 ms of delay (source: kit requirement, indicated by the operator)"
                VERIFY BY JUDGEMENT "the operator, who measures the delay between the input of the stream card and its output"
  …
  VARIANT sensore = di
    USES   Morsetti
    COMPOSED OF
      microfono : MicrofonoMisura
      di        : DirectBox [0 .. 1]   -- without DI no Loudness (rl3)
  …
    SCENARIO k-s2 EXPECT REJECTED
      @0 s     Ricablaggio.collega(ingresso: ingresso_L, ospite: microfono)
      @0 s     Ricablaggio.collega(ingresso: ingresso_R, ospite: loop)
      @5 s     Ricablaggio.collega(ingresso: ingresso_L, ospite: di)
      @10 s    Modalita.scegli(modalita: misure)
      @10 s    Modalita.attiva(modalita: misure)
  VARIANT sensore = microfono
    COMPOSED OF
      microfono : MicrofonoMisuraELivello   -- a single device, two functions in different phases
  …
END

In the extract the forms of part two reappear:

In the file What it describes Chapter
OFFERS, USES the boundaries of the kit: five provided, two used 12
COMPOSED OF the parts common to every form of the kit 13
VARIANT sensore = di, VARIANT sensore = microfono the choice group of the level sensor 20
di : DirectBox [0 .. 1] the direct box, optional part in the choice di only 19
USES Morsetti in the segment sensore = di a boundary used only with that choice 20
GUARANTEE k4 an entity guarantee, in words 12
SCENARIO k-s2 an entity scenario, with the name of the CSC in front of every name 18

Scenario k-s2 describes the microphone and the direct box connected to input L at the same time, and must be rejected. The rule is expressed by guarantee ri1 of the CSC Ricablaggio: input L hosts only one device at a time. The scenario is written in the segment sensore = di because it names the direct box, which is present only with that choice.

In the choice microfono the same microphone performs two functions in different modes: it measures the room in Misure and acts as level sensor in Riproduzione. The language provides no form for a part that performs a function only in certain modes (chapter 19). The description therefore treats the microphone of this choice as an entity of its own, MicrofonoMisuraELivello, which provides both signals, even though the physical device is a single one. The decision is declared in the comments of the file. For the same reason the phone, needed only in Taratura (calibration), a procedure of Riproduzione, appears in Impianto1b as an always-present part.

The report

$ bcdd check --strict Kit1b.csc
bcdd check --strict Kit1b.csc
lines: 123 (recognised 104, comments 18, blank 1, unrecognised 0)
blocks: 1
  line 5: ENTITY Kit1b VERSION 0.2, STATUS HYPOTHESIS
    line 8: OFFERS Modalita in Modalita.csc at line 8: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 9: OFFERS Misura in Misura.csc at line 5: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 10: OFFERS LetturaLivello in LetturaLivello.csc at line 6: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 11: OFFERS Ricablaggio in Ricablaggio.csc at line 8: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 12: OFFERS RilevamentoLivello in RilevamentoLivello.csc at line 4: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 13: USES Programma in Programma.csc at line 4: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 14: USES IngressoAmplificatore in IngressoAmplificatore.csc at line 5: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 16: computer : Calcolatore1b in Calcolatore1b.csc at line 4: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 17: flusso : SchedaFlusso in SchedaFlusso.csc at line 4: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 18: cattura : SchedaCattura in SchedaCattura.csc at line 6: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 19: loop : CavoLoop in CavoLoop.csc at line 5: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 43: USES Morsetti in Morsetti.csc at line 7: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 45: microfono : MicrofonoMisura in MicrofonoMisura.csc at line 4: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 46: di : DirectBox in DirectBox.csc at line 6: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 88: microfono : MicrofonoMisuraELivello in MicrofonoMisuraELivello.csc at line 7: VERSION 0.1, STATUS HYPOTHESIS, no errors

1. ERRORS: 0

2. DEGREE OF THE CONTRACTUAL LINES
  verbal: 5
  formal: 0
  declared extension: 0
  unrecognised: 0
  line 20: GUARANTEE k1 verbal
  line 22: GUARANTEE k2 verbal
  line 24: GUARANTEE k4 verbal
  line 47: GUARANTEE k3 verbal
  line 89: GUARANTEE km2 verbal

3. UNDECIDED: 0

4. PENDING APPROVAL, NOT CONTRACT: 0

5. UNRECOGNISED LINES: 0

6. UNDECLARED TYPES: 0

7. CSCs NAMED BUT NOT CHECKED: 0

8. USES WITHIN ENTITIES: 11
  line 16: computer uses AudioUsb: it is provided by flusso (line 17), cattura (line 18)
  line 17: flusso uses Programma: Kit1b uses it from outside (line 13)
  line 17: flusso uses IngressoAmplificatore: Kit1b uses it from outside (line 14)
  line 18: cattura uses SegnaleMisura: it is provided by microfono (line 45) (in: sensore = di)
  line 18: cattura uses SegnaleMisura: it is provided by microfono (line 88) (in: sensore = microfono)
  line 18: cattura uses SegnaleLivello: it is provided by di (line 46) (in: with di)
  line 18: cattura uses SegnaleLivello: nobody provides it (in: without di)
  line 18: cattura uses SegnaleLivello: it is provided by microfono (line 88) (in: sensore = microfono)
  line 18: cattura uses Riferimento: it is provided by loop (line 19)
  line 19: loop uses UscitaAnalogica: it is provided by flusso (line 17)
  line 46: di uses Morsetti: Kit1b uses it from outside (line 43) (in: with di)

9. COMPOSITIONS: 3
  line 5: ENTITY Kit1b: 3
    sensore = di, with di
    sensore = di, without di
    sensore = microfono

10. DECLARED ABSENCES: 2
  line 18: without di: the part cattura uses connector SegnaleLivello: no other part of Kit1b provides it, nor does Kit1b use it from outside
  line 43: without di: the public connector Morsetti of Kit1b (used) is not assigned to any part

outcome: no errors

The report is read with the rules of the previous chapters.

At the top, under the block ENTITY Kit1b, bcdd lists the cited boundaries and parts, each with its file, version, STATUS and the outcome of the check (chapters 12 and 13). Of the parts bcdd reads only the OFFERS and USES lines; their parts and the CSCs they cite are checked in their respective files (chapter 13).

Section 2 lists five entity guarantees, all in words: the description of the kit does not use the formulas of part three. Section 4 is empty because every guarantee has its own STATUS RATIFIED BY D-20.

Section 8 shows the rule “every used boundary is offered” (chapter 13) applied to every composition. The first entry shows that the part computer uses AudioUsb, provided by two parts: the stream card and the capture card. The rule requires every used boundary to be provided by at least one part; that two parts provide the same boundary is not an error. The entries with the suffix (in: …) apply only in the compositions indicated (chapter 19).

Section 9 lists three compositions, not four. The group sensore has two choices, and the optional direct box doubles only the compositions of the choice di, because it appears in the segment of that choice (chapters 19 and 20).

Section 10 lists two declared absences, both in the composition without the direct box. Without the direct box no part provides SegnaleLivello to the capture card, and Morsetti, which the kit uses from outside in that choice, is not assigned to any part. The two absences correspond to errors E14 and E16 of chapter 13. Here they are not reported as errors because the missing part is optional; with the direct box present both disappear. In the composition sensore = microfono the level signal is provided by the microphone, and nothing is missing.

The kit inside the listening system

The entity Impianto1b contains the kit as a part, kit : Kit1b, together with the source, the amplifier, the loudspeakers and the phone. The choices of the kit appear in its compositions, preceded by the name of the part (chapter 20):

8. USES WITHIN ENTITIES: 6
  line 12: kit uses Programma: it is provided by sorgente (line 13)
  line 12: kit uses IngressoAmplificatore: it is provided by amplificatore (line 14)
  line 12: kit uses Morsetti: it is provided by amplificatore (line 14) (in: kit.sensore = di)
  line 15: diffusori uses Morsetti: it is provided by amplificatore (line 14)
  line 16: telefono uses Modalita: it is provided by kit (line 12)
  line 16: telefono uses LetturaLivello: it is provided by kit (line 12)

9. COMPOSITIONS: 2
  line 4: ENTITY Impianto1b: 2
    kit.sensore = di
    kit.sensore = microfono

10. DECLARED ABSENCES: 0

There are two compositions: from outside only the choices of the group sensore of the kit are distinguished, while its optional part does not generate separate compositions (chapter 20). The kit uses Morsetti only with the choice di, and in the listening system the amplifier provides it.

The limits of the report

The report confirms that the files are written correctly and that, in every composition, every used boundary is provided by a part, except for the declared absences. It attests nothing else:

Summary

Special cases

A choice with the incorrect part. If in the choice sensore = microfono the part microfono : MicrofonoMisura, which provides only the measurement signal, is written by mistake, no part provides the level signal to the capture card:

1. ERRORS: 1
  line 18: [E14] the part cattura uses connector SegnaleLivello: no other part of Kit1b provides it, nor does Kit1b use it from outside (in: sensore = microfono)

In the composition without the direct box the same omission remains a declared absence, because the optional part justifies it; in the choice microfono no optional part justifies it, and the omission is an error. Section 8 brings the two compositions concerned together in a single entry, separating them with ;:

  line 18: cattura uses SegnaleLivello: nobody provides it (in: sensore = di, without di; sensore = microfono)