I am not sure. Maybe the power supply of your laptop, which in turn powers the Bela over USB, is not the best? Can you try powering the board with some other means? Like, a mobile phone charger, a battery or another computer? You can run the Bela patch at boot by setting it from the configuration tab of the IDE. Also, a recording of the noise you hear may help (you can use the code below to log your audio input to disk, based on 07-DataLogging/logging_sensor (see there for more details) :

#include <Bela.h>
#include <WriteFile.h>

WriteFile file1;

bool setup(BelaContext *context, void *userData)
{
    file1.init("out.bin"); //set the file name to write to
    file1.setFileType(kBinary);
    return true;
}
void render(BelaContext *context, void *userData)
{
    for(unsigned int n = 0; n < context->audioFrames; ++n) {
        for(unsigned int c = 0; c < context->audioInChannels; ++c) {
            file1.log(audioRead(context, n, c));
        }
    }
}

or you can use [writesf~] in PureData to create an audi ofile

I just recorded it :
https://instaud.io/1Qd1
I did it with [writesf~( . I didn't manage with your code, I have to set a filename or specific directory? How so? I know nothing about c++

the reason why the code failed is because it was missing an empty cleanup() function:

void cleanup(BelaContext *context, void *userData){}

That noise is normally audible only if you boost the gain of the audio inputs (there is a setting for pga-gain in the IDE), but normally you do not hear it for the normal gain values (~10dB). Also, can you confirm what was your playback device and what it was doing? It's clearly silent, so you may want to play back some sound for comparison. Also, the volume on the playback device should be fairly high (up to 11 max?) and you should - if needed - reduce the pga-gain on Bela.

Sorry, annoying newbie posts, I'm more and more puzzled...
I tried to record again with the same pd patch :

alt text

and now after a few seconds bela stops and I get these messages :

Xenomai/cobalt: watchdog triggeredCPU time limit exceededmake: *** [runide] Error 152Makefile:502: recipe for target 'runide' failedBela stopped
root@bela ~/Bela#

is there something wrong with my patch?

you are definitely missing a / in front of root, not sure why that would cause this problem, though. Maybe a Pd thing

Ok, that's weird, unless there is some ground loop - which should not be the case if the other device is battery powered. Do you hear a similar noise when the output of Bela is disconnected from the other device ? Also, I shall assume you do not hear that noise when listening directly from the other device. I remember similar noise from cheapo mp3 players in the 2000's where their display was interfering with the audio signal...

I get the same thing from my soundcard (decent stuff, rme fireface) and directly from my laptop (makbook pro, battery powered). I just noticed something : holding the unplugged jack (connected to the bela input) in my hand, i hear a (normal) buzz. And then if I touch my laptop or my soundcard with my other hand, I hear the hiss on top of it.

As mentioned here:

giuliomoro I would expect something similar if the electronic device in question shares the ground with the computer you are using to power the Bela: you would get a ground loop that would in turn result in noise, more like a hum than a hiss, though. So if you are plugging anything that is connected to the computer (e.g.: headphone out, soundcard, or any device connected to the mains earth, if the computer itself is earthed), try something "floating", like a battery-powered device (like a mobile phone, for instance) or any mains-powered device that is not connected to earth.

this is expected if the audio device you connect to Bela shares the same ground as the USB connection. This includes the situation where Bela is powered from your laptop and the soundcard is connected to your laptop. I believe this is an unfortunate consequence of the design of the ground on the BeagleBone (in fact it got better on the PocketBeagle).

Ok, i powered it with an adaptor, no hiss anymore. I'm still going to find a way to get rid of this, as it will be inconvenient to work without being able to connect bela to my laptop.
Thanks for your tips, it's been helpful.

if you have a spare active DI box around with ground lift, that should help.