New technologies and ancient sounds

Hello everyone, this is an article about DIY design and production of an original musical instrument.

I once saw an electronic “harp” construction set with 7 laser diodes and a simple tone generator on the frame. And so I wanted to do better and more – the project began Optoharp. As always, it doesn’t matter to me whether such a product exists in the world, what’s important is the desire to create and bring your own ideas.

What solutions were chosen, how they were implemented through thorns, whether a trumpet or a harp happened – read below

Determination of dimensions, number of notes

Since the project is experimental, I chose the average size of the tool – approximately 500mm on the deck.

The strings are replaced by beams. For the optical “strings” I decided to use infrared LEDs so that the rays were not visible. The choice of IR is also determined by the available receivers – phototransistors; almost all of them operate in the IR region.

On classical harps there are a large number of notes, up to 48, so many could not fit here. First, I had to decide on the minimum allowable distance between the “strings”, since I did not know how much I could focus the beam so that it would not catch neighboring sensors. After calculations and experiments with focusing with different lenses, it was possible to achieve a discrepancy of ~15mm at a beam length of 430mm. This is how a compromise was born between the sizes, the number of notes, and the distance between the beams.

Total – 20 notes, pitch between strings 19mm, soundboard length 510mm, harp height 500mm. IR emitters on the bottom in the deck, phototransistors (FT) on top in the tuning frame.

Frame

3-D model developed in SolidWorks, link to files at the end of the article. When modeling I was guided by photo from the Web (95% of photos of harps are from only one angle, wtf), availability of materials and cutting capabilities. I had a 3 W sound speaker, just round without frills. She determined the thickness of the deck.

The design of the classical harp is a rigid and durable frame in the form of a triangle – at the bottom there is a resonator body (soundboard), at the top there is a tuning frame with fastening strings, a column is parallel to the strings. But during the design process I thought ahead – about ease of portability and decided that the harp body should be collapsible.

At the same time as being able to be disassembled, the structure must be rigid and not play anywhere, so as not to disrupt the optical lines of the “strings”. The pegs frame and column are made of a box-like structure (2 plywood walls and wooden slats between them), which gave rigidity and allowed photo sensors and wires to fit. In the desire to make it more elegant, I abandoned visible fasteners and assembled almost everything with glue. Yes, it is impossible to disassemble and debugging occurs simultaneously with assembly.

The column is fastened to the deck using powerful steel angles. Masking the corners is paper tape coated with the same varnish. They are fastened with screws, I don’t know any other option.

  3D model

3D model

The curve of the peg frame should be beautiful and similar to real harps. A few hours in SolidWorks and you're done. The photodetectors are located in the pin frame, and there are many wires coming from them. It is better to make it not completely removable, but folding onto the deck; this will also reduce the degrees of freedom during assembly. I found a point where I could make a turning loop, designed a movable part of the peg frame and a fixed curl. Articulation occurs through a thick pin with a tight fit.

Scimitar or falchion?

Scimitar or falchion?

The point of attachment of the tuning frame to the stand is a collapsible connection, which should be invisible and also be rigid. It uses a tongue-and-groove system with M6 screw fastening through the top of the frame. The screw is completely hidden inside the frame. In general, I had to play with the angle of mating of the parts, adjusting all the points – the axis of rotation, the coordinates of fastening the curls, the angle of inclination of the stand to the deck.

The main inconvenience is that when adjusting the electronics, the curl cannot be secured back to the deck by closing the size ring. The curl is attached to the side wall of the deck, and it is placed last. Clothespins, clamps, tape – everything went into use).

The entire body was sawn from 4mm plywood, in some places thin plastic covered with paper tape. The varnish is “amber”, here I have a crooked hand, there are drips and stains.

I took all the components that were most affordable, in terms of price and timing. Since I’m not entirely confident in the success of the project, it’s just being done for fun. You can always improve it, order laser cutting, milling, boards, 3D printing… Anticipating comments on this matter))

Lensing

Each LED should emit a narrow, parallel beam of light. I immediately excluded lasers from the project – I didn’t want visible rays, and IR lasers are expensive. It would still be necessary to expand the laser beam to reliably hit the FT.

The existing LEDs give a divergence of 25°, which is certainly a lot. The configuration of the LED lens body produces an extended source. If you focus the beam with an additional lens, this will give an image of the entire LED, increased in size, and the larger the size, the shorter the focus of the lens.

How to deal with this – you can use LEDs without a lens, for example SMD, this is almost a point source. This option is very inconvenient for manual assembly, they are difficult to mount and adjust the location, or you need a board for each LED, and 20 pieces will cost a lot.

Option 2 (implemented) – block the luminous flux of a conventional 5 mm LED, creating an artificial point. The easiest way turned out to be to make covers from tin with a 0.8 mm hole opposite the LED axis. This helped; with a lens with a focal length of 25mm, at a distance of 420mm, the beam formed a spot no more than 15mm in diameter. The intensity has decreased slightly, but there is guaranteed no illumination of neighboring receivers.

The lenses themselves – they turned out to be difficult to find; it seems that the Chinese comrades have already done everything. But no, I didn’t find cheap 10mm plastic lenses in bulk (without disassembling the flashlights). Cabochons saved me – glass “lids” for making medallions and earrings. They can be found in the handicraft sections. These are plano convex lenses, not perfect, but almost without distortion. Glass is even better.

Quite normal lenses

Quite normal lenses

Lens mount

A good option is to print housings for lenses and with a holder for the LED. However, I had an even and rigid polyurethane foamcut cubes with holes from it. The cradle is not a fixed mount for the LED, since the optical axis had to be selected for each note. I already imagined hours of torment with invisible rays and movements of fractions of a millimeter.

Lenses glued to the inner edge, at an angle of 50°

Lenses glued to the inner edge, at an angle of 50°

There were no problems with phototransistors (except for finding suitable ones). I secured everything in the cable channel with superglue. Pitch from 19 mm to 21 mm. The cable channel with them was glued to the plywood of the tuning frame.

Phototransistors in a cable channel

Phototransistors in a cable channel

All FTs are on a tuning frame

All FTs are on a tuning frame

Simultaneously with the assembly of the structure, wires were installed, since many cavities were closed forever. The main electronics are mounted on the side wall of the deck, and are covered with an edge with lenses. On the other wall of the deck there is only a column; this wall was installed after adjusting the optics, which added risk. I made the bottom of the deck removable and hidden with screws. This gives access to the controllers and battery.

Electronics and algorithms

The folk one is used as a control controller board based on STM32F103С6Т6

An important issue in the entire design is the reliable operation of the phototransistor [ФТ] from interruption of the light flow. At the reception of the beam, the FT photocurrent should be such that it creates more than 2.4 V at the load resistor (logical 1 for STM at the level of 2.2 V) and at the same time the photocurrent from background daylight illumination should not create more than 0.8 V at the resistor (level log. 0). This means the light beam must clearly hit the FT (how can this be done on a prefabricated structure?) and be bright, which will allow the installation of a low-resistance load resistor. FT took SHF300.

There were thoughts of switching the FT to a 5-volt power supply so that there would be a voltage reserve on the transistor in the open state. But I went towards better focusing, so that there were no undefined levels, and not all inputs of the MK are tolerant of 5V.

To reduce the number of inputs involved, I used dynamic switching between two groups. That is, 2 adjacent FTs are loaded with 1 resistor, it is connected to one discrete input of the MK. The LEDs are also grouped into even and odd groups. This is done so that not all rays light up at once, but after 1, and there is no stray light from a neighboring LED. Therefore, 2 FTs can be placed in parallel per 1 input, but for reliability, the FT groups are also powered in turn. That is, one of the FTs in a pair is always disconnected from the power supply and the corresponding LED is also turned off. When illuminated by a neighboring LED or background illumination, the voltage on the resistor is determined only by the powered FT. Explanatory picture below.

Scheme of operation of emitters and receivers

Scheme of operation of emitters and receivers

The result was 10 pairs of FTs, all connected to 10 inputs of the GPIOB register. Also, 2 groups of 10 LEDs, connected in series, 2 each (1.25V * 2 + ballast = 5V power). They are switched together with the FT power supply by two GPIO outputs through transistor switches. I made the board with the keys using LUT.

Logic of beam operation

  • The first group of LEDs turns on (odd notes)

  • Pause 1 ms to skip FT photocurrent transients.

  • Periodic polling of 10 discrete inputs, detection of shading/release of each note, increment of the shading time counter

  • If the shading time is no more than 0.7 seconds, then the corresponding note of the initial amplitude is created.

  • After the 10th FT, the group switches to even notes, and the process repeats. Group switching frequency 300 Hz.

About notes

From music theory I only knew about 7 notes and octaves. In general, I don’t understand this, and in order to find out the frequencies of notes and their positions on the harp, I went to Wikipedia. Reading:

…there is not enough room for the strings of the full chromatic scale, so the harp is strung only to produce the sounds of the diatonic scale.

So, it doesn’t become any clearer, let’s read what it is

Chromatic scale is an ascending or descending melodic movement in semitones, built, as a rule, on the basis of a major or minor scale. Diatonic scale – a modal scale in which all major seconds are filled with passing semitones.

We need sheet music! Here's the musical notation:

For example, the musical notation of a seventh chord and its inversions captures the “thirds” logic of the chord, regardless of one or another musical system. The alteration sign, which refers to the diatonic level of the modal scale, can mean its chromatic alteration in the system of major-minor tonality…

How many new words… Okay, I finally figured it out and found the frequencies.

Instrument frequency ranges

Instrument frequency ranges

Since my optoharp has a smaller range than the orchestral one, I had to choose where to place it. I looked at the ranges of guitars and other instruments, and selected the first note BEFORE the third octave (C3, 131 Hz), the last note A (A5, 880 Hz) of the fifth octave, which gives almost 3 octaves. It will work for a start, then you can reprogram it.

The spectral composition for the harp is also not easy to find – 2 indistinct pictures without numbers, and from the phrases “the harp has a gentle, but relatively quiet timbre”, “more saturated sound” you can’t code much. Okay, I downloaded examples of sound recordings and ran them through a spectrum analyzer. The components of the spectrum turned out to be as follows, on average.

Screenshot of harp audio from GoldWave

Screenshot of harp audio from GoldWave

Frequency relative to base frequency

Level relative to base frequency, for “desaturated sound”

Level relative to base frequency, for “sound with overtones”

1 (0th harmonic)

100%

100%

2 (1st harmonic)

9.7%

18%

3 (2nd harmonic)

0.3%

15%

4 (3rd harmonic)

2.4%

5%

5 (4th harmonic)

10%

32%

The number of overtones in the spectrum is not very large, which allows us to limit ourselves to 4 harmonics for the computational load on the MK.

Synthesis of sounds.

I chose a simple and economical method that allows flexible adjustment of tones and harmonics – a table synthesizer. An array (1024) is stored in memory in 1 period of the sin signal; the cell number label runs cyclically through the array with a given step, which corresponds to the pitch of the note. Sampling frequency and main timer for all calculations – 16 kHz.

The values ​​taken from the array with the required step give the flow of the sin signal of the fundamental frequency of the note, then it is multiplied by the volume of the 0th harmonic. The flows for higher harmonics are obtained in the same way, with a multiply increased step of the cell number counter in the same array. The initial volume of all harmonics is taken from the table above.

To save calculations, it would be possible to make an array with harmonics in advance. However, in reality, different harmonics decay at different rates, and for synthesis flexibility I did everything separately. The MK speed at a 16 kHz cycle is enough to calculate five harmonics of each note.

The duration of a note is determined by the rate at which the amplitudes decrease. Since the reduction is exponential, it can be realized by cyclically multiplying by a number close to 1. For the first harmonic the value taken is 62/64, for the second 61/64, for the third and higher harmonics 60/64. That is, every n milliseconds the amplitude is calculated as A1 = A1 * 62 / 64. These are features of integer calculations.

Duration of sound of different harmonics

Duration of sound of different harmonics

The cycle period n depends on the “note duration” control and the nominal duration of each note, which depends on the pitch of the note. The regulator connected to the analog input of the MK adjusts the overall scale. The range from 0.2 sec to 4 sec was experimentally selected. With a short playing time, the harp turns into a balalaika, with a medium playing time – like a harp, with a long playing time – like a piano/double bass.

With a clock frequency of 16 kHz, all playing notes are summed. To reduce the load, the note is turned off when the amplitude drops less than 0.7% of the initial one. Amount exposed nonlinear transformationso that there is no overload, but even one note can be heard well. The function of converting the sum of signals into output Out = x / (x >> 10 + 1200), with one note sounding at 29% of the total volume, and five notes at 77%.

Musical features

In a real harp, as in other stringed instruments, the shape of the excitation pulse is similar to that in a guitar. The composition of overtones in the spectrum, and therefore the timbre of the sound, also depends on the method of plucking and on the place of excitation. Here, measuring the location of the pinch would be difficult to implement, so I made such a dependence on the duration of shading of the “string”. If the time is long, then there are few overtones, the sound is smooth, if you touch the “string” quickly, then higher harmonics are proportionally added, making the sound sharper, guitar-like.

// ct[ni] - длительность удержания струны, от 1 до 200 тактов
harma =  8 - ((ct[ni]) >> 3); //зависимость высших гармоник от времени удержания, 1..64 = ампл гармоники =  8...0
if (harma < 0 ) harma = 0;
Amp4[ni] = Harm[4] + 41*harma; // Начальная амплитуда 4й гармоники, с добавлнием коффицента удержания

That is, there is the possibility of changing the timbre. Holding the string for a long time, from 0.7 s, there will be no sound at all. I did the debugging by my own ears, so I don’t know whether it turned out right.

Generation and analog part

The sound itself is generated by hardware PWM with the maximum frequency and number of levels 1600. With a zero signal at the output there is a square wave with a frequency of 40 kHz, which is normally filtered by a low-pass filter.

Signal filtering and amplification

I calculated and made a second-order low-pass filter on an operational amplifier. The cutoff frequency is approximately 5 kHz. The result was a small board, immediately with a Jack 3.5 connector for a speaker and an external volume control.

Amplifier circuit with low pass filter

Amplifier circuit with low pass filter

Note display

Since in the version with IR rays the rays themselves are not visible and it is difficult to understand the position of the fingers when they overlap the rays, I made an indication of the operation.

Along the holes for the lenses in the deck I made a second row of holes for 3 mm LEDs. I picked it in the same way as on real harps – notes C – in red light, notes B – in blue, the rest are white.

LEDs stand next to IR emitters, but with a tricky geometric feature. When playing, the soundboard of the harp is at a steep angle to the musician's plane of vision, almost along the axis of vision. Because of this, LEDs placed exactly to the left will appear further away than their corresponding IR emitters. Experiments have shown that the brain perceives it as perpendicular (correspondence of the indicator to the hole), with a shift of approximately 40% to the axis of vision.

To control the indication LEDs, a separate board on the same STM is used, connected to the main MCU via UART. The parcel is 4 bytes in size, sent 62 times per second. You can switch the type of indication – either an indication of a shaded “string”, or an indication after release while this note is sounding.

Pin B.2, which is located separately on the board in the Boot connector, cannot output a log. 1, changed this pin to A.2

Nutrition

Uses 1 18650 battery, converting to 5 Volts and 3.3 Volts. A charging module is also present. The remaining charge is indicated using the same indicator LEDs. When you turn on the harp, the charge level is displayed in the first second by the first four indicator LEDs.

Assembly and configuration

The adjustment of the IR LED beams took place on the almost assembled structure with clothespins. Each FT was connected to a 30 kOhm load resistor (I adjusted some resistors for clearer operation of the photodetector), a voltmeter was connected to it, and the LED was connected to a current source. By moving around the focal point of the lens left-right and up-down (since the spot has a gradient that can be caught), the location of the maximum signal from the FT was found. In this position, the LED was fixed with hot glue, and until the glue hardened, the position was adjusted again to find the maximum signal. Hot melt adhesive has an optimal time; other adhesives either take a long time or harden quickly. I had to tinker with the first LEDs, there is the greatest distance to the FT. But then things went even faster than I expected; the focal point was quickly found. The positioning accuracy is 0.5 mm or less, while the hot-melt adhesive does not float and fixes normally. The plywood with the lenses was also glued rigidly, surprisingly, but there were no long adjustments. It takes longer to solder all the wires.

General view

General view

Folded state

Folded state

Technical Parameters

Note range: 20 notes, from C3 (131 Hz) to A5 (880 Hz)

Harmonics: 4, timbre depends on hold duration.

Dimensions: 580 x 520 x 80mm

Weight: 850 g

Power: 18650 3.7V battery

Consumption: 250..500 mA depending on volume

Note duration control and volume control, harp/piano mode switch.

Flaws

You can't achieve everything, especially in the first version. There is no way to get to the IR LEDs and phototransistors if something goes bad. The rays cannot be corrected either, but it is unlikely that they will be shot down. There is no tone or spectrum adjustment to simulate other instruments without reflashing the MK. There is no sound of strings hooking, like in cool synthesizers. There is no additional audio output for external audio equipment (there is one, but it is occupied by a speaker). The optoharp does not work in bright sunlight; the light interferes with the receivers.

Guess the melody ©

Due to my lack of ear for music, I can say that it works and makes sounds. Comparing with recordings of playing the harp, it’s similar.

Based on the videos, MIDI recorded 2 melodies:

Classic Lose Yourself Eminem (intro)

https://rutube.ru/video/b04d66b7365ada778ed40154fe46749e/

/// here will be a link to the recording in a few days ///

Soundtrack to The Lord of the Rings The Lord of the Rings theme

https://rutube.ru/video/43530fd2fd2cd5219813dd08e4f45b8e/

/// here will be a link to the recording in a few days ///

Thank you for your attention!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *