What is the basic algorithm the brain uses when it's trying to express something? If there's some kind of map of meanings and corresponding sounds, are the closer signals closer in sound (phonetically) or in meaning (semantically)?
This is a very difficult question to answer! And the best I can offer is, right now, we don't really know—these mental structures are still very much a mystery!
are the closer signals closer in sound (phonetically) or in meaning (semantically)?
"Closer" is hard to define. But one way to study this is priming.
Basically, if you show people a series of real words ("water", "rock", "tree") and fake words ("bliff", "wug", "slomp"), and ask them to categorize them into "real" and "fake", they'll generally do it at a certain base speed. But if a word's been "primed"—if the subject has seen it recently, for example—then they'll respond much faster than that base rate.
And studies have shown that words can be primed both phonetically and semantically! In other words, showing someone words like "back" and "bang" will prime the word "bank", but showing them words like "money" and "loans" will have the same effect!
What does this tell us? Well, the structures our brains use to store all these concepts are still very, very mysterious. But they're definitely stored in a way that's linked together both by sound and by meaning. What exactly this structure is remains to be discovered.
There was a paper by Huth and colleagues in 2016 which seemed to somewhat reinvigorate interest in a detailed semantic map of the brain:
More recently, the same group at Berkeley (or at least sharing some members) have shown the validity of their semantic maps in a modality-independent way. That is, whether you are listening to or reading a story doesn't matter; the same cortical areas are activated:
There are many caveats to this kind of research. IMO the main two are:
philosophical, e.g. just because reading semantically related words is associated with higher activity in one cortical region does not mean that that is where the words 'are' in the brain.
methodological/statistical, e.g. can we trust the semantic distance metrics, as computed from text corpora?
Nevertheless, this research is interesting. Just don't take it as the be-all and end-all of 'how words are sorted in the brain'; it's just one cutting-edge example of the kind of results modern neuroimaging plus computational/statistical methods can return.
We don't really know, but ...
The brain uses associative (content addressable) memory, so sound and semantics don't need any special mapping ('cry' near 'dry', or 'cry' near 'sad') -- instead, things like temporal order of events (timestamps) or memories about what other people know (shared knowledge) could benefit greatly by using neural proximity (proximity in the connected network, not necessarily in physical space) instead of additional 'code'.